loopx icon indicating copy to clipboard operation
loopx copied to clipboard

[Bug]: the presentation public-boundary scan certifies unlabeled GitHub, AWS, Slack, Google, Stripe, npm, PyPI and JWT credentials as public-safe

Open JasonBuildAI opened this issue 1 month ago • 3 comments

Impact / 影响

scan_public_boundary_text (loopx/presentation/public_safety.py) is the self-described canonical public/private boundary check for generated presentation text. Four shipped surfaces gate on it:

  • loopx/dash_server.py serves dash HTML and JSON endpoints only when the scan returns ok (withholds with a 500 otherwise);
  • loopx/cli_commands/dash.py refuses to write the loopx dash generate --out file when the scan fails;
  • loopx/presentation/static_site.py raises StaticSiteContractError and refuses to publish a bundle file when a scanned text file fails the tuple;
  • loopx/chat_manager_details.py publishes conversation detail text only when the scan is clean (otherwise it substitutes [sensitive text omitted]);
  • loopx/capabilities/manager_context/roundtrip.py rejects a result returned over a shared manager channel when the reply text fails the scan.

Its pattern table (PRESENTATION_PUBLIC_BOUNDARY_PATTERNS in loopx/public_safe_text.py) carries only three arms: an absolute-local-path arm, a private-key-material arm, and a credential-assignment arm that recognizes labeled api[_-]?key=, auth[_-]?token= and access[_-]?token= assignments. It recognizes no provider-issued token shape at all.

A provider credential embedded in presentation text without one of those three labels — for example a GitHub PAT inside a pasted CI log or a git remote -v URL, an npm/PyPI token in a publish log, a JWT in a step summary — is therefore certified ok: true with no warning. On upstream/main 2f544f969:

shape text rendered into the dash/roundtrip surface before
GitHub classic PAT ghp_… (36 chars, unlabeled) {"ok": true, "warnings": []}
GitHub fine-grained PAT github_pat_11… {"ok": true, "warnings": []}
AWS access key id AKIA… {"ok": true, "warnings": []}
AWS session key id ASIA… {"ok": true, "warnings": []}
Slack bot token xoxb-… {"ok": true, "warnings": []}
Google API key AIzaSyA… {"ok": true, "warnings": []}
Stripe live key sk_live_… {"ok": true, "warnings": []}
npm token npm_… {"ok": true, "warnings": []}
PyPI token pypi-… {"ok": true, "warnings": []}
JWT eyJ…header.payload.signature {"ok": true, "warnings": []}

The scan is fail-closed by design: its consumers treat ok: true as a positive certification that the text is safe to serve, write to disk or accept into a shared conversation. A credential that passes it is published with that certification, and credential disclosure is irreversible until the token is rotated.

Reproduction

On upstream/main 2f544f969, from a source checkout with uv sync --extra test:

from loopx.presentation.public_safety import scan_public_boundary_text

text = "CI log fragment: pushed with ghp_A1b2C3d4E5f6G7h8I9j0K1l2M3n4 to the registry mirror"
print(scan_public_boundary_text(text))
# {"ok": True, "warnings": []}   -- synthetic token shape; a live value behaves identically

The same text handed to loopx dash generate renders into HTML that the boundary gate then certifies, and the same text returned over a manager channel is accepted by the roundtrip check.

Why this is high importance

  • Affected surface: the canonical public/private boundary check for generated presentation text, gating the session dash server, the CLI dash export, chat detail publication and manager-channel result return — i.e. every agent run whose results or step text reach a dashboard or a shared conversation.
  • Who pays: any operator or agent whose tool output contains an unlabeled provider credential. Common real carriers: git remote -v URLs with embedded PATs, CI/publish logs, environment dumps. The receipt says public-safe; the credential reaches a shared surface or a rendered page under that certification.
  • Severity: the same failure class already recorded for the sibling scanners — #7635 (outbound capability scan, fixed by #7636), #7712 (loopx check --scan-path, PR #7713) and #7717 (chat activity masker, PR #7718). Each of those was fixed or is in review for exactly this drift; this surface gates publication the same way and still certifies all ten shapes clean.
  • Not an edge case: the missing shapes are the most common provider prefixes, and the labels the one existing credential arm does recognize are precisely the ones unlabeled values lack.

Root cause

PRESENTATION_PUBLIC_BOUNDARY_PATTERNS in loopx/public_safe_text.py predates PROVIDER_TOKEN_SHAPE_PATTERN_SOURCE (the canonical provider-credential alternation added there for #7635/#7636) and was never composed with it. The canonical owner recognizes all ten shapes; the presentation boundary scan — a consuming surface of the same owner module — recognizes none.

Fix

Add a provider token arm to PRESENTATION_PUBLIC_BOUNDARY_PATTERNS composed from PROVIDER_TOKEN_SHAPE_PATTERN_SOURCE, the same way merged #7636 composed the outbound scanner's rule (re.compile(r"(?i)(?:" + PROVIDER_TOKEN_SHAPE_PATTERN_SOURCE + r")")). One definition, no restated subset; the five consuming surfaces then fail closed on unlabeled provider credentials with their existing typed behavior (withheld endpoint, unwritten output file, [sensitive text omitted], rejected roundtrip).

Boundary

This issue's scope is the presentation boundary scan's pattern table and its focused tests in tests/control_plane/test_presentation_public_safety.py. It does not change any consumer's failure handling, receipt shape or exit-code contract, does not touch redact_public_text (masking in generated text is a separate masking decision, covered for chat activity by #7718), and does not widen the canonical issuer families (the narrower AWS/Slack prefix sets noted in #7635's boundary remain open work for a parity-reviewed follow-up). It inherits the canonical alternation's known over-block: a 20-character-or-longer hyphenated pypi-… slug and a case-folded asia followed by 16 letters can also trip the gate; narrowing that shared alternation is the parity review #7635's boundary already names as separate work.

JasonBuildAI avatar Oct 30 '26 05:10 JasonBuildAI

Verified fixed on current main (87a153d4d): #7732 landed the issue's prescribed composition — the provider token arm in PRESENTATION_PUBLIC_BOUNDARY_PATTERNS compiled from PROVIDER_TOKEN_SHAPE_PATTERN_SOURCE (80252379f), with the focused tests test_unlabeled_provider_tokens_fail_the_boundary_scan and test_ordinary_prose_and_short_provider_lookalikes_stay_public in tests/control_plane/test_presentation_public_safety.py.

Live repro from this issue on main (synthetic shapes): GitHub classic/fine-grained PAT, AWS AKIA/ASIA, Slack xoxb-, Google AIza, Stripe sk_live_, npm, PyPI and JWT all return {'ok': False, 'warnings': ['provider token']}; ordinary prose stays ok: True. Closing looks safe to me — leaving that to a maintainer with close rights.

LIHUA919 avatar Nov 08 '26 02:11 LIHUA919

Re-verified on current main (ff9054376, 2026-11-19) with the issue's synthetic repro: GitHub classic/fine-grained PAT, AWS AKIA/ASIA, Slack xoxb-, Google AIza, Stripe sk_live_, npm, PyPI and JWT each return {'ok': False, 'warnings': ['provider token']}; ordinary prose stays ok: True. The provider token arm composed from PROVIDER_TOKEN_SHAPE_PATTERN_SOURCE is in place in loopx/public_safe_text.py (merged #7732), with the focused tests in tests/control_plane/test_presentation_public_safety.py (test_unlabeled_provider_tokens_fail_the_boundary_scan, test_ordinary_prose_and_short_provider_lookalikes_stay_public). Closing still looks safe — leaving that to a maintainer.

LIHUA919 avatar Nov 19 '26 14:11 LIHUA919

System.Collections.Hashtable[7727]

JasonBuildAI avatar Nov 21 '26 03:11 JasonBuildAI