Skip to content

fix(security): harden sessions, financial bounds, and administrator invariants - #577

Draft
dev-fani wants to merge 24 commits into
mainfrom
security/session-integrity-20261030
Draft

dev-fani wants to merge 24 commits into
mainfrom
security/session-integrity-20261030

Conversation

@dev-fani

@dev-fani dev-fani commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Harden refresh-family rotation/revocation, atomic password reset with primary-database authorization, financial amount validation, and concurrent administrator changes. Preserve all bounded compatibility repairs. Blocked draft: not ready to merge or deploy.

MP4 validation checkpoint

Latest 7f80bab309641eaa272be2cbc54d6231bc75b4c2 fixes the dispute upload service's incorrect MP4 signature offset and reconciles its MP4 branch with the existing helper paths. All prior fixes including0ca1388 and explicit worker restrictions remain preserved; #572/#576 unchanged.

Primary ISO/IEC14496-12:2008 §§4.2–4.3 and Apple box documentation establish size/type layout: a leading ftyp type starts at byte4, not0. Existing prefix-only helpers also needed the full supplied view for declared-box bounds instead of a16byte slice.

One shared recognizer now verifies a complete leading FileTypeBox: exact type bytes, standard/extended/EOF size forms, minimum fields, complete declared extent, aligned printable brand fields and byte-view offsets. Extended sizes remain exact bigint, with no allocation based on declared size. It does not search for markers elsewhere.

This recognizes a container header, not whole-video validity, profile/codec conformance, playability or safety. No decoder, later-box parser, registered-brand allowlist or media-processing feature was added. A leading ftyp remains the supported recognition scope. See docs/contracts/mp4-evidence-header.md.

Authorization, evidence ownership, hashes of full uploaded bytes, configured decoded/base64/body limits, storage behavior and non-MP4 checks remain unchanged. Header errors retain400/VALIDATION_ERROR before file/metadata writes. Orphan-file compensation after metadata failure remains a separate unresolved contract; not repaired here.

Validation

Isolated Node24.22.1/TS5.9.3/Vitest3.2.7/Prisma5.22snapshot and matching client; network-none containers, disposable PG16/Redis7 private sockets and temporary synthetic evidence only. No production evidence/credentials, real mail, financial transactions or worker activation. Local runtime differs from frozenCI20.

  • 299 affected tests pass,0fail/skip. Accounts for prior113pass/1failure: all original114cases now pass, plus185new regressions (95header cases and90HTTP cases). The original MP4acceptance assertion was not changed, skipped or marked expected-failure.
  • Covers standard/minimal/extended/EOFheaders, synthetic box sequences, binary minor versions, every truncated standard/extended header length, undersized/unaligned/oversized/huge lengths, wrong/high-bit markers, markers at unrelated offsets, malformed brands and Buffer/Uint8Array view offsets.
  • Actual HTTP matrix now142cases: authorized standard/extended uploads preserve full bytes/SHA256/stable uploader, all87invalid vectors return400without writes;401/403/409/404, unsupported/wrong MIME, configured-size400and body413preserved. Other MIME and existing storage/ownership regressions retained. Final142HTTPcases rerun pass after response typing.
  • All106security tests pass,0fail/skip. Build exits0with0diagnostics before/after. Typecheck retains exactly10preexisting diagnostics,0added/removed; no changed-file errors or weakened types.
  • Affected strict lint/format, whitespace and Prisma validate pass. Repository lint5errors/4warnings unchanged; format28→27because affected schema file formatted. No broader cleanup or check changes.
  • Schema/migrations unchanged; schema-push component fixtures are not full migration replay. Prior duplicate-index replay failure and unknown target upgrade state remain.
  • Current-head CI41645965394 fails audit53(5low/24moderate/20high/4critical) and format27. FrozenNode20 installs pass; lint/typecheck and downstream build/test skipped. Unchanged workflows inspected; no matching release/deployment trigger.

Worker execution restriction preserved

Indexer polling, notification delivery and fraud-activity cleanup remain blocked. CLI runs only liveness heartbeat/shutdown; no job consumers/schedules/replay or environment activation switch. Pending data/jobs/repeat definitions remain stored. Logs and queue/indexer status expose unavailable jobs/reasons; unrelated endpoint authorization is unchanged. This does not make the application fully operational.

Activation still requires reviewed consumer completion/ordering/idempotency/coverage/checkpoint recovery, notification outbox/ambiguous-send/backlog treatment, evaluator-aligned reliable retention frontier/window consistency/bounded deletion/restart recovery and a separate code/rollout decision. Older consuming binaries must be replaced for restricted rollout; backlog/storage/lag can grow.

Remaining groups and next task

Private report/handoff retain the complete grouped evidence, reusable work, minimum correction and completion criteria. MP4 bounded blocker is closed; broader gates remain.

  • Next bounded task: reconcile stale disputes/interface/routes.integration.spec.ts imports and actual route-factory/plugin contract (2diagnostics), reusing reviewed canonical routes and the142case HTTP matrix. Preserve authorization/content headers/storage; not started here.
  • Remaining10type diagnostics: dispute route fixtures2,escrow SDK fixtures4,fraud route factory fixture1,notification fake signature1,user unlink fixture1,E2E mail fixture1. Resolve canonical contracts without weaker assertions/types; clean typecheck required.
  • Orphan file after metadata insertion failure: confirmed behavior; compensation/recovery semantics need separate review and failure tests. No cleanup policy invented here.
  • Style5errors/4warnings/27format paths: exact behavior-preserving fixes and unmodified repository gates must pass.
  • Audit53: compatible remediation/policy disposition for runtime/SDK axios/follow-redirects/toml/zod and tooling tinypool/handlebars/brace-expansion/source-map-js/vite; frozen install/audit/provider/SDK checks required. No blanket ignore or threshold change.
  • Fresh29migration replay still fails at duplicate driver_profiles_tier_idx in20260828000000_analytics_indexes. Need history-safe strategy preserving applied files; redacted target migration history/checksums/catalog/client and representative sanitized upgrade remain unknown. Component tests do not certify deployment.
  • Complete full-suite/coverage/E2E remain unproven: stale dispute/fraud route fixtures, notification repeated-markFailed expectation and inherited isolated metrics502cases remain. Existing60%coverage gates apply; prior fleet-list/refund/upload fixture repairs stay resolved.
  • Supported-runtime artifact/startup and coordinated auth/session rollout/recovery remain required. Local24build is not CI20/deployed26certification. Quiesce old session writers; match schema/clients/binaries; preserve revocations/families, normal accessJWT expiry and legacy-refresh login-again policy.
  • Escrow ABI remains uncertain: pinned smartcontract12cc0e04source create_escrow has7args including optional fleet_id; backend retains6. Need deployed network/address/Wasm/spec binding and explicit compatibility decision, then local conformance tests. No invented argument/default; bare-u64 evidence remains independent.
  • Worker activation, SMTP/event completion/retry/recovery and retention prerequisites remain deployment blockers. Whole parked M10/retention projects and owner-list feature remain outside this repair.

No merge, deploy, forcepush, checks/settings change, contributor action or unrelated repair. Stop after this MP4 correction.

Restore only the missing historical removeDriver tail and retain its three
PostgreSQL regressions. The valid prefix and every existing test assertion
remain unchanged; both files match the reviewed #576 versions exactly.

Reused-from: #576 at 6aa01f0
Original-repair: ec85132
Historical-tail: 75b121e

The three regressions and 106 security tests pass. TS1160 is resolved;
existing semantic errors, fraud syntax errors, listing conflicts and strict
lint warnings remain. This is not merge or deployment approval.
Recover the thirteen historical assessment cases and exercise strict rule
boundaries, configured windows, repository calls and full-assessment alerts.
Restore the already-consumed optional rule dependency type and make the
in-memory count fake honor the existing cap. Evaluator runtime is unchanged.

Based on structural evidence f4a320f
and contract reconciliation 0171533;
no configuration, retention, worker or processing repair is imported.

18 assessment and 106 security tests pass. Build/typecheck remain blocked
by 90/162 existing semantic diagnostics; no new semantic diagnostics.

Co-authored-by: dev-fani <wavesgrips@gmail.com>
Reuse the independently applicable M03 restoration from
218c177. Preserve actor-alert exports,
registry metrics, dispatch concurrency and existing async/error semantics.
Retain its five real composition regressions and verify counter identity,
labels and the real metrics endpoint with one additional test.

88 focused tests (including all 18 assessment cases) and 106 security
regressions pass. Real ESM imports succeed; build/typecheck diagnostics
fall from 90/162 to 61/116 with no additions. Full checks still fail.

No worker registration, business processing, replay, retention or schema
changes. Existing loss/retry and process topology limitations remain.

Co-authored-by: dev-fani <wavesgrips@gmail.com>
…lity

Reuse the independently applicable M04 imports/status reconciliation and
minimal storage port prerequisite. Preserve persisted/API values, escrow
status separation, historical ownership rules and transaction behavior.
Add real module HTTP role/status/ownership and schema coverage.

Reuse reviewed checkpoints b34d832 and
76f120c without importing their broader
repair branch. All 11 reused files match reviewed blobs exactly.

Validation: 114 focused dispute tests, 52 HTTP cases and 106 security tests
pass; focused strict lint/format pass. Build 61->43 and typecheck 116->91
existing diagnostics, none added. Full repository gates remain blocked.
Reuse only the four-file reviewed adapter/payout-error slice from
bf8124e (dev-fani, 2026-10-28).
Bind canonical fleet ports and shared unsigned-XDR builder, use configured
network, restore recorded payout argument order, and retain typed 404 errors.
No membership/listing, authorization, financial or processing redesign.

Validation: 28 focused tests and all 106 security tests pass; focused lint
and format pass. Build 43->39 and typecheck 91->87, no new diagnostics.
Broader fleet 27 pass/4 known failures/5 setup-blocked cases. Full repository
gates remain red. Preserve ff6fa37 and all earlier security repairs.
Selectively reuse the two reviewed files from 2453f1c by dev-fani <wavesgrips@gmail.com>. Restore settings and canonical send-port wiring without changing retry or delivery policy.

57 focused and 106 security tests pass in isolation. Build/typecheck diagnostics decrease 39/87 to 36/84 with no additions.
Restore the nullable readAt mapping introduced by 1beff8c (rustdavolee) and lost in merge a13feca. Existing additive migration remains unchanged; no backfill or new migration.

Verify owner-scoped read state through real authenticated routes and Prisma, existing-row component migration, timestamp preservation and schema parity. 67 notification and 106 security tests pass. Build/typecheck diagnostics 36/84 to 33/80 with no additions.
Selectively reuse six reviewed files from 0171533 by dev-fani <wavesgrips@gmail.com>. Preserve the newer assessment tests, rules, thresholds, hour windows, alert behavior and cleanup implementation.

Add five real module HTTP/Prisma authorization and assessment regressions. 95 focused fraud/config tests, five HTTP tests and all 106 security tests pass. Build/typecheck diagnostics fall33/80 to30/56 with no additions.
Restore the original d942f79 not-found hierarchy and missing membership export. Preserve custom fleet messages and existing payout mapping. Complete the existing optional duplicate-invite error with the shared ConflictError contract and align its chain ID with canonical bigint callers.

No repository, production guard wiring, membership/listing or payout behavior changes. 42 focused fleet and 106 security tests pass; build/typecheck30/56 to25/51 with no additions. Seven baseline broad-suite fixture conflicts remain unchanged.
Use the established singleton owner/page/limit repository contract from 75b121e. Honor page offsets with validated integer boundaries and stable newest-first ties. Preserve removed-member defaults from f9cd04c while reconciling fake/repository/auth/schema fixtures with those contracts.

86 focused fleet and 106 security tests pass. All seven previous fleet failures resolved. Build25/type50 remain; import repair exposes three latent multi-wallet/pageSize errors in the unwired owner-list skeleton. Its result/API policy is documented as blocked, not guessed.
Remove only list-my-fleets.ts and its exclusively local input/result/use-case types after verifying no imports, barrel exports, dynamic registration, routes, scripts, tests, or supported package API consume it. Private server package has no library entry point. Retain established singleton-owner repository pagination and every functioning fleet path.

86 fleet and 106 security tests pass with no skips. Affected lint/format pass. Build/typecheck25/50 to22/47: exactly the three retired-file errors removed, no additions.
Restore the wallet ownership contract introduced by fbaa40e (Blackdavid1) and lost in merge a358617. Require the existing injected wallet repository and pass typed authenticated user/caller inputs without the historical body cast. Preserve all route/schema/hook/builder and transition contracts.

67 delivery, 86 fleet and 106 security tests pass. Build/typecheck22/47 to17/42 with no additions. Existing fallback test uses an owned wallet to reach its unchanged502 assertions.
Align optional refund-status identifier with canonical bigint ports. Validate the source-contract bare-u64 range at escrow builder HTTP, application and direct encoder/adapter boundaries without Number conversion or changed argument order. Preserve existing six-argument create shape; pinned reference has a separate seventh fleet_id ABI gap requiring deployment evidence.

Refund fixtures now inject the existing status dependency, preserving assertions and policy. 125 builder/identifier, 67 delivery, 86 fleet and 106 security tests pass. Build/typecheck17/42 to16/37 with no additions.
The private application and its tests use fraud-detection/index.ts. The alternate file introduced in 05d04da has no consumers and refers to router, repository and dependency contracts that never existed. Remove that unimportable dead root while preserving the canonical factory, rules, authorization and optional alertPublisher implementation.
Keep indexer polling, notification delivery and fraud cleanup inactive under the explicitly authorized execution restriction. Separate loading from liveness startup, omit consumer construction and scheduling, and expose the fixed blocked reasons in logs and queue/indexer status. Preserve pending jobs and repeat definitions; activation requires reviewed recovery and retention prerequisites rather than an environment switch.
Replace cast incomplete dependencies and stale inputs with scoped canonical repository/storage/ownership fixtures. Preserve MIME acceptance/rejection assertions, correct two synthetic PDF headers, and retain hash/identity/persistence/error coverage. The MP4 acceptance case remains failing on the existing service offset mismatch; production validation and worker execution restrictions are unchanged.
Share bounded MP4 header recognition across the upload service and signature helpers. Check standard, extended and EOF box sizes against the supplied view and validate brand-field layout without scanning later content or claiming whole-video safety. Preserve authorization, limits, hashing/storage and worker restrictions; add malformed-header and real HTTP regressions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant