Skip to content

[Bug]: Edge-case inputs like zero, negative, empty, and degenerate values are not consistently blocked #21

Description

Summary

Severity: HIGH

Several qwed-tax guards do not consistently reject edge-case inputs such as negative monetary values, zero denominators, empty corporate substance, or economically impossible payloads. Instead of failing closed, some paths continue calculation, collapse degenerate values into defaults, or return a verified-looking result.


Problem

In a financial verifier, these are not harmless edge cases — they are high-risk manipulation points.

Affected patterns include:

  • Negative amounts not being rejected
  • Zero totals collapsing into ratios of 0
  • Degenerate company-state inputs still producing residency determinations
  • Zero-price valuation paths not being blocked before division/math

Why this violates QWED philosophy

QWED requires:

  • All edge cases must fail closed
  • No silent defaults that mask missing or invalid data
  • Unproven results must never be treated as valid

If a system can still produce a success-like result when the underlying economic input is impossible or incomplete, the verification boundary is not safe.


Affected scope

This pattern appears across multiple guards:

  • qwed_tax/guards/remittance_guard.py
  • qwed_tax/guards/poem_guard.py
  • qwed_tax/guards/valuation_guard.py
  • Payroll and other money-handling verification paths

Attack scenario

Negative remittance amount:

verify_lrs_limit(amount_usd=-500000, purpose="education", financial_year_usage=200000)

A negative remittance can distort remaining-limit logic rather than being rejected immediately.

Degenerate corporate substance:

determine_residency(
    company_name="ShellCo",
    is_foreign_incorp=True,
    turnover_total=0,
    turnover_outside_india=0,
    assets_total=0,
    assets_outside_india=0,
    employees_total=0,
    employees_outside_india=0,
    payroll_total=0,
    payroll_outside_india=0,
    key_management_location="OUTSIDE"
)

This can still produce a residency result even though all economic substance inputs are zero.

Zero-cap valuation:

verify_conversion(
    investment="100000",
    cap="0",
    discount="1",
    next_round_price="100"
)

This can drive the effective price to zero and enter an invalid valuation path.


Security impact

This can enable:

  • Manipulation of threshold logic with negative amounts
  • False confidence from impossible economic states
  • Crashes or undefined behavior in valuation math
  • Legal/tax outcomes produced from nonsensical or insufficient inputs

These are high-risk because they sit at the exact place where an attacker would try to bend rule evaluation.


Fix direction

  • Reject negative amounts, rates, and payments unless explicitly legal and modeled
  • Reject zero or missing denominators in ratio-based tests
  • Reject economically impossible all-zero corporate substance inputs
  • Add explicit precondition checks before any division or threshold logic
  • Treat empty/degenerate states as BLOCKED or UNVERIFIABLE, not as computable outcomes

Goal

qwed-tax should never produce a verified or usable financial/legal result from impossible, incomplete, or degenerate inputs.

Edge cases must be blocked before they influence tax logic.

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