Skip to content

[Bug]: Middleware and facade APIs declare full verification after checking only a subset of tax legality #19

Description

Summary

Severity: HIGH

Some qwed-tax execution-facing paths return high-assurance success states after verifying only a narrow slice of the overall tax/legal problem. One verified subcomponent is being presented as if the whole transaction were proven correct — a partial-verification bug.


Problem

The clearest example is payroll middleware that checks gross-to-net arithmetic and then returns a fully verified/executable result, even though other legally material checks were never run:

  • Worker classification
  • Withholding legality
  • W-4 exempt eligibility
  • Reciprocity withholding state
  • Filing or reporting implications

A system that proves only arithmetic but returns VERIFIED for a payroll action is overstating assurance.


Why this violates QWED philosophy

QWED requires:

  • Partial verification must never be treated as full verification
  • Unproven results must never pass as valid
  • Trust boundaries must be honest about what was actually checked

Affected scope

Primary affected path:

  • qwed_tax/middleware/gusto_interceptor.py

Related orchestration surface:

  • qwed_tax/verifier.py

Representative issue:

  • verify_us_payroll() only checks gross-to-net math through PayrollGuard
  • Middleware then returns a fully successful execution decision

Attack scenario

An upstream AI or system submits a payroll payload that is mathematically balanced but legally wrong.

Example cases:

  • Worker is W-2 but being processed as a contractor
  • Withholding treatment is invalid
  • Exempt handling is wrong
  • Filing/state-tax implications are incorrect

If the numbers balance, the middleware can still return:

{
  "status": "VERIFIED",
  "execution_permitted": true
}

This gives downstream systems the impression that the payroll action is tax-safe, when only arithmetic consistency was checked.


Security impact

This can allow:

  • Illegal payroll execution
  • False confidence in downstream payment systems
  • Incorrect classification or withholding decisions to survive as long as the math balances
  • Trust-boundary misuse where integrators believe "verified" means full tax verification

In financial systems, this is a serious assurance-labeling bug.


Fix direction

  • Narrow success semantics so arithmetic verification is labeled only as arithmetic verification
  • Do not return full VERIFIED / executable status unless all relevant legal checks have run and passed
  • Introduce layered result states that distinguish:
    • Mathematical verification
    • Legal/tax verification
    • Execution approval
  • Require orchestration of all applicable payroll checks before allowing execution

Goal

qwed-tax should never present subset verification as full transaction verification.

If only one part of the tax/legal problem was checked, the result must say exactly that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions