ts-cve-2026-extension-gateway-chain-defensive
Task
A TypeScript extension gateway lives under /testbed. It accepts base64-encoded
extension bundles, extracts bundle files, stores a manifest, serves imported
assets, validates partner callback URLs, and renders small operator-facing HTML
cards from extension templates. It also supports conditional render rules,
short-lived share links for private extension assets, and signed approval
decisions that can change extension publication state. Operators can clone an
existing extension for the same tenant.
Audit the full TypeScript source tree, identify every distinct security root cause visible in the implementation, and harden the trust boundaries. The final service must preserve legitimate extension workflows while rejecting malformed or unsafe inputs as client errors.
After patching the source, write /app/output/findings.json as a JSON array.
Each entry must include:
cve: a stable identifier for the finding; do not leave it blankvulnerability_type: a CWE identifierseverity:LOW,MEDIUM,HIGH, orCRITICALaffected_files: a list of modified file paths under/testbed(relative such assrc/bundles.tsor absolute such as/testbed/src/bundles.ts)root_cause: a brief explanation of the underlying flawdescription: the attack vector and impact
Before and as you work, maintain /app/output/plan.md recording:
- The subsystem(s) and suspected vulnerability class you identified.
- The root cause you traced.
- The fix approach and why it addresses the root cause.
- How you verified the fix.
This plan is graded for process quality independently of whether every deterministic test passes.
Required Behavior
Preserve normal behavior:
GET /healthreturns HTTP 200 while the service is healthy.POST /api/extensions/importaccepts ordinary base64 bundle JSON with a manifest and relative files.- Valid private extensions are readable by their own tenant through
/api/extensions/{tenant}/{extensionId}/assets/{alias}. - Valid public extensions are readable through
/api/public/extensions/{tenant}/{extensionId}/assets/{alias}. - Valid callback URLs for approved HTTPS partner hosts are accepted.
GET /api/extensions/{tenant}/{extensionId}/renderreturns an HTML preview for safe template variables.- Simple safe render conditions continue to work for operator previews.
- Valid share tokens issued by the service can retrieve the intended private asset.
GET /api/extensions/{tenant}/{extensionId}/report.csvreturns a CSV summary for valid imported extension metadata.GET /api/extensions/{tenant}/{extensionId}/handoffredirects only to valid approved partner destinations.POST /api/extensions/{tenant}/{extensionId}/approveaccepts a valid signed approval action and applies the intended publication decision.POST /api/extensions/{tenant}/{extensionId}/clonecan clone an existing extension for the same tenant.- Legitimate requests must continue to work after earlier malformed requests are rejected.
Security requirements:
- Treat every value that comes from an extension bundle, request path, query string, JSON body, or generated client-facing token as untrusted until it is validated for the exact operation being performed.
- Fix root causes, not isolated payloads. A rejected operation must not mutate shared defaults, persisted records, filesystem state, tenant visibility, or later request behavior.
- Apply conservative resource caps while expanding extension bundles. For this gateway, single bundle members in the hundreds of KiB and bundles with scores of entries are oversized and should be rejected before any partial filesystem state is written.
- Keep tenant, extension, asset, URL, rendering, reporting, cloning, approval, and token decisions scoped to the exact boundary that authorized them.
- Preserve supported workflows. Do not solve the task by disabling import, asset serving, public asset serving, callback acceptance, rendering, report export, handoff, approval, clone, or share-token functionality.
- Prefer small auditable validation and canonicalization helpers over endpoint special cases.
Environment
- Source lives in
/testbed. - The service is started with
node /testbed/src/server.ts. - The verifier starts the service on
localhost:9090. - Node 24 is available and can execute TypeScript source directly.
Constraints
- Fix trust-boundary primitives rather than adding special cases for one test value or one endpoint.
- Do not disable extension import, asset serving, callback validation, public asset serving, template rendering, report export, handoff, approval, clone, or share-token retrieval.
- Do not replace endpoints with canned responses or reject all bundles, callbacks, templates, or assets.
- Do not introduce new third-party dependencies.
- Do not edit verifier files or rely on hidden verifier state.