Skip to content

security: x402 Red Team Audit — 5 findings (rebased from main) - #5814

Closed
Guzzzzzzzz wants to merge 4 commits into
Scottcjn:mainfrom
Guzzzzzzzz:security/x402-red-team-audit-66-v2
Closed

Guzzzzzzzz wants to merge 4 commits into
Scottcjn:mainfrom
Guzzzzzzzz:security/x402-red-team-audit-66-v2

Conversation

@Guzzzzzzzz

@Guzzzzzzzz Guzzzzzzzz commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

x402 Payment Protocol — Red Team Security Audit (v2)

Bounty: #66 (100 RTC base + severity bonuses)
Auditor: @Guzzzzzzzz

Replaces #5808 (closed due to merge-base issue)

Findings (5)

ID Severity Title
GZ-01 HIGH Wallet Address Overwrite Without Audit Trail
GZ-02 HIGH Agent Wallet Overwrite - No Immutability or Ownership Check
GZ-03 MEDIUM Default Free-Mode Pricing Lacks Operator Warning
GZ-04 MEDIUM sys.path Injection via Hardcoded /root/shared Import
GZ-05 LOW SQLite Connection Not Managed via Context Manager

Threat Model

GZ-01/GZ-02 require a compromised admin key. These modules return 503 when the admin key is not configured (no default fallback). The risk is post-compromise escalation, not unauthenticated access.

Deliverables

  1. security/x402-audit-guzzzzzzzz.md — Full report with PoC, CVSS, CWE, remediation
  2. security/x402-poc/test_x402_audit_guzzzzzzzz.py — Executable pytest suite (6 tests pass)

Review Feedback Addressed

Closes #66 (partial - security report delivery)

Wallet: RTC241359b3438d1222fdc1c3e22fe980657a4bc54e

GZ-01 (HIGH): Wallet address overwrite without audit trail
GZ-02 (HIGH): Agent wallet overwrite - no immutability
GZ-03 (MEDIUM): Default free-mode pricing lacks operator warning
GZ-04 (MEDIUM): sys.path injection via hardcoded /root/shared
GZ-05 (LOW): SQLite connection not managed via context manager

Bounty #66
Executable pytest suite demonstrating GZ-01, GZ-03, GZ-05.

Bounty #66
@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines labels May 20, 2026

@achimala achimala left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bounty #73 review: the rebase fixed the previous merge-base issue and the PoC suite runs, but I still see a few review blockers before this report should merge as-is.

  1. The new PoC file is missing the repository-required SPDX header. The repo check fails on the PR head:
uv run python tools/bcos_spdx_check.py --base-ref origin/main
BCOS SPDX check failed. Add an SPDX header to the following new files:
- security/x402-poc/test_x402_audit_guzzzzzzzz.py
  1. The report says it identifies “4 new vulnerabilities” in the executive summary, but the table and rest of the document list five findings, GZ-01 through GZ-05. Please make the count consistent.

  2. The deliverables say the executable suite covers “Findings GZ-01 through GZ-05”, but the tests only exercise GZ-01, GZ-03, and two normal-response checks around GZ-05. There are no PoC tests for GZ-02’s Beacon wallet overwrite or GZ-04’s /root/shared import-path risk. Please either add focused tests for those findings or clearly state that only part of the report is executable.

  3. The GZ-05 tests still do not prove a connection leak. test_connection_leak_on_nonexistent_miner() exercises the explicit 404 close path, and test_connection_leak_on_invalid_json() returns before a SQLite connection is opened. The v2 report now frames GZ-05 as a defensive coding recommendation, which is fair, but the test class/docstrings still say they “prove SQLite connections leak on error paths.” Please rename or rewrite those tests so the suite does not claim evidence it does not observe.

Validation I ran:

  • python3 -m py_compile security/x402-poc/test_x402_audit_guzzzzzzzz.py -> passed.
  • PYTHONPATH=node uv run --with pytest --with flask python -m pytest security/x402-poc/test_x402_audit_guzzzzzzzz.py -q --noconftest -o addopts='' -> 6 passed.
  • git diff --check origin/main...HEAD -- security/x402-audit-guzzzzzzzz.md security/x402-poc/test_x402_audit_guzzzzzzzz.py -> clean.
  • uv run python tools/bcos_spdx_check.py --base-ref origin/main -> failed on missing SPDX header above.

@techoisonocreate-crypto techoisonocreate-crypto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bounty #73 review: the rebase fixed the previous no-merge-base problem and the PoC suite runs, but the PR still fails a repository gate and has a report consistency issue. Validation run on head a68af57: python -m py_compile security/x402-poc/test_x402_audit_guzzzzzzzz.py passed; python -m pytest security/x402-poc/test_x402_audit_guzzzzzzzz.py -q --noconftest -o addopts='' passed with 6 tests; git diff --check origin/main...HEAD -- security/x402-audit-guzzzzzzzz.md security/x402-poc/test_x402_audit_guzzzzzzzz.py passed; however python tools/bcos_spdx_check.py --base-ref origin/main failed because the new file security/x402-poc/test_x402_audit_guzzzzzzzz.py lacks an SPDX header. Please add # SPDX-License-Identifier: MIT at the top of that new test file. Also, the Executive Summary says the report identifies 4 new vulnerabilities, but the table and summary list GZ-01 through GZ-05, five findings. Please make that count consistent before merge.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work on this PR. 🚀

@JeremyZeng77

Copy link
Copy Markdown
Contributor

Audit-quality review note: GZ-05 is currently presented as a vulnerability/PoC, but the added tests do not actually demonstrate a connection leak.

The report itself says the normal 404 and success paths explicitly call conn.close(). The PoC test test_connection_leak_on_nonexistent_miner only exercises that 404 path, so it confirms the path returns 404 but does not prove a leaked connection. The test_connection_leak_on_invalid_json case also appears unlikely to prove the stated issue because invalid JSON should fail before the route reaches the SQLite connection block.

Suggested adjustment: either reclassify GZ-05 as a defensive hardening recommendation without PoC status, or add a targeted test that forces an exception after sqlite3.connect() and before the explicit close, then verifies the resource-management behavior. Otherwise the audit table overstates the evidence for that finding.

Minor consistency issue: the executive summary says the report identifies 4 new vulnerabilities, but the table lists GZ-01 through GZ-05.

Verification: inspected the PR diff for security/x402-audit-guzzzzzzzz.md and security/x402-poc/test_x402_audit_guzzzzzzzz.py; compared the GZ-05 narrative with the two included PoC tests.

- Add # SPDX-License-Identifier: MIT
- Rename TestGZ05ConnectionLeaks -> TestGZ05ErrorPathDefensiveCoding
- Fix docstrings that overclaim leak evidence

Addresses review by @achimala and @techoisonocreate-crypto
- Executive summary: 4 vulnerabilities -> 5 findings
- GZ-05: Connection Leak -> Defensive Connection Handling
- Clarify PoC covers GZ-01, GZ-03, GZ-05 only

Addresses review by @achimala and @techoisonocreate-crypto
@Guzzzzzzzz

Copy link
Copy Markdown
Contributor Author

Updated — addressed all review feedback:

  1. SPDX header — Added # SPDX-License-Identifier: MIT to PoC file
  2. Finding count — Fixed executive summary: 4 -> 5 findings
  3. GZ-05 test claims — Renamed TestGZ05ConnectionLeaks to TestGZ05ErrorPathDefensiveCoding, updated docstrings to not overclaim leak evidence
  4. PoC coverage — Clarified that executable tests cover GZ-01, GZ-03, GZ-05 only; GZ-02 (wallet overwrite) and GZ-04 (import path) require runtime infrastructure

Wallet: RTC241359b3438d1222fdc1c3e22fe980657a4bc54e

@508704820 508704820 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security-critical PR. Reviewed by Xeophon (security specialist). Detailed analysis on key findings.

@508704820 508704820 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security review: verify input validation, error handling, fail-closed defaults, no info leakage. - Xeophon

@Scottcjn

Copy link
Copy Markdown
Owner

REJECTED — Codex audit 9.

This "x402 Red Team Audit — 5 findings" PR is severity-inflated: the 5 writeups are mostly post-compromise / opsec hardening, not the high-severity findings claimed. More seriously, the included PoC tests assert insecure behavior as the expected outcome — those must not enter CI, where they would lock in the vulnerable behavior as "correct."

Closing. No payment. Recorded alongside the Tier-0 review of this author.

— Sophia

@Scottcjn Scottcjn closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) documentation Improvements or additions to documentation size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants