- Comprehensive Workspace Audit - 2026-06-10.md - C1-Secrets-Rotation-Checklist-2026-06-10.md - Mistral-Outsource-Package-2026-06-10.md - Workflow-Remediation-Plan-2026-06-10.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 KiB
title, tags, created, updated, status
| title | tags | created | updated | status | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Comprehensive Workspace Audit - 2026-06-10 |
|
2026-06-10 | 2026-06-10 | open |
Comprehensive Workspace Audit - 2026-06-10
Full workspace audit across nested Git repositories under /Users/manwe/CascadeProjects/escrow.
Primary product focus was the multi-shop branch:
frontend/:feature/white-label-shopsbackend/:feature/white-label-shops
No code, build, deployment, pipeline, Docker, or secret files were changed during this audit.
Scope
| Repo | Branch audited | Status at audit time | Notes |
|---|---|---|---|
frontend/ |
feature/white-label-shops |
Dirty worktree, ahead of remote | Multi-shop UI, tenant admin UI, Telegram Mini App, wallet/payment flows. |
backend/ |
feature/white-label-shops |
Clean worktree, ahead of remote | Tenant routes, storefront routes, payment services, file services, webhooks, scanner integration. |
deployment/ |
main |
Dirty worktree, ahead of remote | escrow-multi stack and environment material. |
scanner/ |
development |
Clean worktree, ahead of remote | Go payment scanner and balance-watch service. |
amanat-assist/ |
main |
Dirty worktree | Assist frontend plus local LLM proxy. |
nick-doc/ |
main |
Dirty worktree | Documentation vault, tenant docs, prior audits. |
Related lighter repo/documentation scan: Multi-Shop Branch Project Scan - 2026-06-10.
Method
- Read project instructions from root
AGENTS.md, rootRTK.md, andnick-doc/AGENTS.md. - Enumerated all nested Git repositories.
- Confirmed frontend/backend were on
feature/white-label-shops. - Reviewed mounted backend routes and service boundaries for auth, tenant isolation, file access, payment state, webhooks, and scanner integration.
- Reviewed frontend app routes, auth/token storage, debug surfaces, API proxying, and dependency/runtime quality.
- Reviewed deployment compose files and tracked environment-file posture without printing secret values.
- Ran a sanitized secret scan that reported only file/path/line/pattern class, never values.
- Ran available read-only verification commands.
Executive Summary
The most urgent risks are not cosmetic. They are live operational/security risks:
- Tracked deployment
.envfiles and additional key-shaped literals need immediate secret rotation and history cleanup. - The frontend-to-assist LLM path is unauthenticated and can proxy arbitrary model calls.
- Tenant bot claim URLs are returned from a broad bot-list route and can leak capability tokens to lower tenant roles.
- Generic file delete/info routes authorize only "logged in", not file ownership.
- The Request Network intent route still defaults to trusting client-supplied payment amount unless oracle quoting is explicitly enabled.
- Several payment routes compare JWT user ids directly against Postgres UUID payment fields, causing false-deny and inconsistent checkout/payment behavior.
Finding Register
| ID | Severity | Area | Status |
|---|---|---|---|
| C1 | Critical | Secrets and credentials | Open |
| C2 | Critical | LLM proxy exposure | Open |
| H1 | High | Tenant bot claim authorization | Open |
| H2 | High | File delete/info authorization | Open |
| H3 | High | Client-trusted payment amount | Open |
| H4 | High | Payment UUID/JWT identity mismatch | Open |
| H5 | High | Dependency advisories | Open |
| M1 | Medium | Frontend typecheck bypass in builds | Open |
| M2 | Medium | Browser token storage | Open |
| M3 | Medium | Permit relay ownership/rate limit | Open |
| M4 | Medium | Production debug surface | Open |
| M5 | Medium | Scanner operational auth footgun | Open |
| M6 | Medium | Backend/frontend lint health | Open |
| L1 | Low | Deployment/dev defaults | Open |
| L2 | Low | File upload reliability and MIME hardening | Open |
Critical Findings
C1 - Tracked env files and key-shaped material require rotation
Evidence
deployment/.envis tracked.deployment/.env.devis tracked.deployment/escrow-multi/docker-compose.ymlloads.envdirectly.- Sanitized scan found token-shaped assignments in tracked deployment env files.
- Sanitized scan found private-key-shaped or key-like hex material in backend tests/reports/source, scanner tests/config/comments, and docs.
Representative locations, values intentionally omitted:
deployment/.envdeployment/.env.devbackend/__tests__/decentralized-payment-verifier.test.tsbackend/__tests__/payment-edge-cases.test.tsbackend/__tests__/payment-integration.test.tsbackend/__tests__/request-network-webhook.test.tsbackend/__tests__/sweep-service.test.tsbackend/__tests__/transaction-safety-provider.test.tsbackend/src/services/payment/decentralizedPaymentService.tsbackend/usdt-reset-test-report.mdscanner/balance_test.goscanner/config.gonick-doc/01 - Architecture/Request Network Integration Constraints.mdnick-doc/08 - Operations/Handoff - RN Multichain Probe - 2026-05-28.mdnick-doc/10 - Services/scanner.mdnick-doc/11 - Testing/Escrow Marketplace E2E Procedure.md
Impact
Tracked env files and any real private-key material must be treated as exposed. If these values were ever valid, repository history, backups, forks, and local clones can retain them.
Recommendation
- Rotate all credentials found in tracked env files.
- Triage key-shaped literals into fake/test fixture vs real. Rotate any value that was ever used.
- Replace test keys with generated fixtures or env-var references.
- Move env files to untracked local templates:
.env.example,.env.dev.example. - Add ignore rules and pre-commit/CI secret scanning.
- History-clean only after rotation plan is agreed, because rewrite affects every clone.
C2 - Public unauthenticated LLM proxy path
Evidence
frontend/src/app/api/llm/route.ts:8accepts POST requests with no auth, rate limit, schema check, or body-size cap, then forwards arbitrary JSON toLLM_PROXY_URL.amanat-assist/llm-proxy/index.mjs:73defaults CORS to all origins whenALLOWED_ORIGINSis empty.amanat-assist/llm-proxy/index.mjs:96reads the full request body without a hard cap.amanat-assist/llm-proxy/index.mjs:128accepts caller-chosenproviderandmodel.amanat-assist/llm-proxy/index.mjs:180logs upstream error data.
Impact
Any unauthenticated internet client that can reach the frontend route can spend provider quota, probe internal proxy behavior, and send unbounded payloads. If prompts include sensitive user data, the route also becomes an ungoverned data egress path.
Recommendation
- Require authenticated Amanat session or service-to-service token on
/api/llm. - Add per-user and per-IP rate limits.
- Validate request schema and allowlist provider/model.
- Enforce body-size caps at the Next.js route and proxy.
- Restrict CORS to known origins.
- Redact/log only status, provider, model class, and request id.
High Findings
H1 - Tenant bot claim URL leaks through broad bot listing
Evidence
backend/src/services/tenant/tenantBotService.ts:75-89returnsclaimUrlfor pending bots.backend/src/services/tenant/tenantBotService.ts:268-270maps all tenant bot rows through that public serializer.backend/src/routes/tenantRoutes.ts:510-518allowsowner,manager,finance,support, anddeveloperto list bots.
Impact
The claim URL contains a capability token. A lower-privileged tenant role that can list bots can obtain a pending bot claim link and potentially claim Telegram admin control for the bot.
Recommendation
- Remove
claimUrlfrom the generic bot-list response. - Keep claim URLs behind the existing owner/developer claim-link route or create a dedicated high-privilege capability endpoint.
- Store only a hashed claim token if practical.
- Add tests for support/finance/manager not receiving claim material.
H2 - Generic file delete/info routes do not enforce ownership
Evidence
backend/src/services/file/fileRoutes.ts:71-82exposes delete routes to any authenticated user.backend/src/services/file/fileRoutes.ts:86-88exposes file-info route to any authenticated user.backend/src/services/file/fileController.ts:247-275checks only that a user is authenticated before deleting.backend/src/services/file/fileController.ts:278-299checks only that a user is authenticated before returning file info.backend/src/services/file/fileService.ts:30-50safely confines paths to upload root, so this is an authorization issue rather than arbitrary filesystem traversal.
Impact
Any logged-in user can target public-upload files under the upload root if they know or guess the path. That can delete avatars, product/request-template/blog assets, or query metadata for files they do not own.
Recommendation
- Replace path-based mutation with file ids tied to an owner/resource.
- Require owner, admin, or resource participant checks before delete/info.
- Keep the existing upload-root confinement.
- Add tests for cross-user delete/info denial.
H3 - Payment intent route defaults to client-trusted amount
Evidence
backend/src/services/payment/requestNetwork/requestNetworkRoutes.ts:41-42enables oracle quoting only whenORACLE_QUOTING_ENABLEDis exactlytrue.backend/src/services/payment/requestNetwork/requestNetworkRoutes.ts:599-678computes amount server-side only when the flag is enabled.backend/src/services/payment/requestNetwork/requestNetworkRoutes.ts:680-689legacy path trusts clientamount.
Impact
If the flag is absent or false in production, a buyer can submit a lower amount than the seller offer requires. The code comment itself marks this as a risk and says to remove the branch after cut-over.
Recommendation
- Make server-side quoting the default and remove the client-trusted fallback.
- Fail closed if seller offer/profile cannot be loaded.
- Persist quote inputs and outputs for auditability.
- Add regression tests that client amount is ignored or rejected.
H4 - Payment route authorization mixes legacy ids and Postgres UUIDs
Evidence
backend/src/db/repositories/drizzle/DrizzlePaymentRepo.ts:915-932resolves and storesbuyerIdas a Postgres UUID.backend/src/services/payment/requestNetwork/requestNetworkRoutes.ts:390-392comparespayment.buyerIddirectly to JWT user id.backend/src/services/payment/paymentRoutes.ts:417-418,440-442, and464-467compare direct payment ids to JWT user id.
Impact
Legitimate buyers can be denied checkout reload, status, or confirmation when JWT ids are legacy ObjectIds but payment rows store UUIDs. Inconsistent route behavior also makes payment support and debugging brittle.
Recommendation
- Reuse the canonical access helper already present in
paymentController.ts. - Normalize user/payment participant checks through one identity utility.
- Add regression tests for legacy JWT id against UUID-backed payment rows.
H5 - Production dependency advisories remain open
Evidence
Frontend production dependency audit:
- 2 critical
- 16 high
- 39 moderate
- 8 low
- Largest critical/high cluster:
protobufjsvia Trezor dependencies infrontend/yarn.lock.
Backend production dependency audit:
- 7 high
- 7 moderate
- Notable packages:
axios,jws,lodash,path-to-regexp,socket.io-parser,validator,ws.
Amanat Assist production dependency audit:
- 0 vulnerabilities reported.
Impact
Wallet, websocket, HTTP, validation, and JWT-adjacent packages are part of high-risk surfaces. Some advisories are transitive and may require careful upgrade testing, but they should not stay invisible in release planning.
Recommendation
- Update lockfiles in a controlled dependency-hardening branch.
- Prioritize frontend
protobufjs/Trezor path and backendaxios,jws,socket.io-parser,validator,path-to-regexp. - Run payment, wallet, Telegram, socket, and checkout smoke tests after upgrades.
Medium Findings
M1 - Frontend builds skip TypeScript errors
Evidence
frontend/next.config.ts:27-29setstypescript: { ignoreBuildErrors: true }.- Frontend lint also reports
@ts-nocheckin payment components.
Impact
Production builds can ship TypeScript failures. This is especially risky while multi-shop, Telegram Mini App, and payment code are changing quickly.
Recommendation
- Remove
ignoreBuildErrorsonce current type issues are cleaned. - Add a separate
tsc --noEmitCI gate if Next build must stay fast.
M2 - Browser token storage increases XSS blast radius
Evidence
frontend/src/auth/context/jwt/auth-provider.tsx:35readsaccessTokenfrom localStorage.frontend/src/lib/axios.ts:69-72sends localStorage token as bearer auth.frontend/src/lib/axios.ts:127-141still supports legacy localStorage refresh token cleanup.amanat-assist/src/services/auth.ts:38-57persists access/refresh token state to localStorage.amanat-assist/src/services/auth.ts:152-163accepts OAuth tokens from URL query params.
Impact
Any XSS can extract bearer tokens. Query-param token handoff can also leak through browser history, analytics, referrers, or logs before cleanup.
Recommendation
- Move toward httpOnly session cookies or a backend-for-frontend pattern for browser sessions.
- Stop carrying access/refresh tokens in URL query params.
- Add strict CSP and minimize inline script risk.
- Keep localStorage only for non-sensitive UI state.
M3 - Permit relay route lacks ownership check and rate limit
Evidence
backend/src/services/payment/requestNetwork/requestNetworkRoutes.ts:257-324relays a signed permit for a payment after validating rail/spender/value.- The route is authenticated but does not verify the requester owns the payment.
- The code comment at
requestNetworkRoutes.ts:255-256notes it should be rate-limited per buyer.
Impact
This can leak pending payment existence and can cause relayer gas spend attempts for payments the requester does not own, provided they have a valid permit payload.
Recommendation
- Require buyer/admin access before permit validation and relay.
- Add per-buyer/per-payment rate limiting.
- Return indistinguishable 404/403 behavior if needed to reduce enumeration.
M4 - Telegram debug panel can show production operational/user data
Evidence
frontend/src/components/debug/telegram-debug-panel.tsx:44-56shows the panel in production for Mini App context or explicit debug request.frontend/src/components/debug/telegram-debug-panel.tsx:73-96displays API/socket URLs, email, role, Telegram platform/version, and initData presence/length.
Impact
This is not direct token leakage, but it exposes user and operational diagnostics in production UI.
Recommendation
- Gate production debug panels behind admin/developer role and signed debug mode.
- Hide email and internal URLs unless explicitly needed.
- Consider stripping the panel from production builds.
M5 - Scanner endpoints are unauthenticated if SCANNER_API_KEY is missing
Evidence
scanner/config.go:115-127readsSCANNER_API_KEYand logs that endpoints are unauthenticated when missing.scanner/api.go:111-126allows all requests when the key is empty.
Positive controls observed
scanner/api.go:135-136caps create-intent body size.scanner/security.go:58-99validates callback URLs against SSRF rules.scanner/security.go:102-127adds dial-time protection for public callback mode.
Impact
The scanner is safe only if production always sets SCANNER_API_KEY and ingress does not expose it unintentionally.
Recommendation
- Fail startup in production when
SCANNER_API_KEYis missing. - Keep the current dev-mode behavior only for explicit local mode.
- Add deployment checks for scanner auth.
M6 - Lint health is currently failing in frontend and backend
Evidence
Backend npm run lint:
- 29 errors
- 996 warnings
- Error classes include forbidden
require()imports, empty blocks, and namespace usage.
Frontend npx yarn@1.22.22 lint:
- 83 errors
- 65 warnings
- Notable correctness errors include conditional React hooks in
frontend/src/sections/telegram/view/telegram-points-view.tsx:59-61and@ts-nocheckin payment components.
Impact
Lint is not just style here. Hook ordering and @ts-nocheck can hide runtime failures in Telegram/payment flows.
Recommendation
- Fix hook-rule and
@ts-nocheckviolations first. - Then decide whether import-sort failures should block release or be auto-fixed.
- Keep lint gating focused enough that teams do not normalize red builds.
Low Findings
L1 - Deployment/dev defaults are footguns
Evidence
deployment/docker-compose.ymlanddeployment/dev-amn/docker-compose.ymlinclude hardcoded dev/default database or Redis passwords.deployment/escrow-multi/migrate/migrations/0018_db_privilege_isolation.sqlcontains role password literalundefined.
Impact
These are not necessarily live production secrets, but defaults can become real accidentally when copied between stacks.
Recommendation
- Replace hardcoded dev credentials with env references and clear examples.
- Fix or remove copied migration files that embed
undefinedpassword literals.
L2 - Upload reliability and MIME hardening gaps
Evidence
- General upload flows rely primarily on MIME validation.
- Chat attachment handling has stronger magic-byte validation, but generic uploads are less strict.
- Non-image multi-file upload code constructs output paths for documents but needs verification that files are moved/copied as expected.
Impact
Potential broken uploads for documents and weaker file-type assurance outside chat.
Recommendation
- Reuse chat attachment magic-byte validation for all user-controlled file uploads where practical.
- Add focused tests for multi-file document upload persistence.
Positive Observations
- Backend mounts raw webhook body parsing before global JSON parsing for Request Network, AMN scanner, and Telegram tenant webhooks.
- Socket.IO connection auth rejects refresh tokens and verifies room membership for chat/request scoped rooms.
- Tenant resolution uses host/slug context rather than trusting arbitrary caller headers.
- Scanner has meaningful SSRF defenses for callback URLs and dial-time checks in the public-callback mode.
- Markdown rendering uses
rehypeRawfollowed by sanitization and protocol restrictions. - Backend
tsc --noEmit -p tsconfig.jsonpassed. - Scanner
go test ./...passed. - Amanat Assist
npm run buildpassed. - Amanat Assist
npm audit --omit=devreported no production vulnerabilities.
Verification Commands
| Repo | Command | Result |
|---|---|---|
backend/ |
npm run typecheck |
Passed |
backend/ |
npm run lint |
Failed: 29 errors, 996 warnings |
backend/ |
npm audit --omit=dev --json |
Failed advisories: 7 high, 7 moderate |
frontend/ |
npx -y yarn@1.22.22 lint |
Failed: 83 errors, 65 warnings |
frontend/ |
npx -y yarn@1.22.22 audit --groups dependencies --json |
Failed advisories: 2 critical, 16 high, 39 moderate, 8 low |
scanner/ |
go test ./... |
Passed |
amanat-assist/ |
npm run build |
Passed |
amanat-assist/ |
npm audit --omit=dev --json |
Passed: 0 vulnerabilities |
Frontend repo declares Yarn 1 and this shell did not have a global yarn binary, so frontend commands were run through npx -y yarn@1.22.22.
Recommended Remediation Order
- Rotate and scrub tracked secret material.
- Lock down
/api/llmandamanat-assist/llm-proxy. - Remove claim URLs from broad tenant bot listing.
- Add file ownership/resource checks to delete/info routes.
- Force server-side payment pricing and remove client-trusted amount fallback.
- Normalize payment participant authorization across UUID and legacy id paths.
- Upgrade vulnerable dependency clusters.
- Fix frontend hook-rule and
@ts-nochecklint failures. - Re-enable strict frontend type/build checks.
- Harden scanner production startup around
SCANNER_API_KEY.
Notes and Guardrails
- Do not print, paste, or document actual secret values while remediating C1.
- Do not change Woodpecker pipelines, Dockerfiles, deploy commands, cache/prune behavior, or production build procedure without explicit approval.
- Frontend/backend code changes require coordinated patch version bumps before build/deploy. This documentation-only audit does not require a version bump.
- Treat
feature/white-label-shopswork as isolated fromescrow-dev/dev-amn; targetescrow-multifor multi-shop deployment work.