Repository navigation
[M2.2e4b1] Verify browser identity and fix generated CSP nonces - #73
Merged
Merged
Conversation
6 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.2e4a-serve-web
branch
from
November 5, 2026 12:41
ded9ee7 to
cab4ea8
Compare
samuelmbabhazi
force-pushed
the
feat/m2.2e4b1-browser-fixture
branch
from
November 5, 2026 12:42
2e487b1 to
b06200d
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
) ## Task [M2.2e4b2] Browser acceptance for account security, stacked on #73. No merge requested. ## What changed and why An uncertain token creation followed by HTTP 429 released the original idempotency key. A subsequent retry could create a second token. Preserve that key through rate limiting while enforcing Retry-After and the existing four-minute replay window. A failing unit regression reproduced the key change before the fix; a browser scenario now drops a real committed response, throttles the retry, and verifies one token and an actual server replay. Extend the isolated Chromium suite with password reset and code reuse rejection; invalidation of other sessions and earlier API tokens; TOTP/recovery login; single-use/replaced recovery codes; token creation and revocation; private-display expiry; concurrent security-write prevention; and late-result suppression after leaving the route. Independent browser contexts verify session rotation against the real backend. Add automated accessibility checks for populated and error states, plus an injection-shaped token name. The recovery-code grid previously used a viewport breakpoint that squeezed two columns into the narrower tablet content area. Size the columns from the available container width instead. Browser measurements now pass at 320, 390, 768, 1024 and 1440 pixels; sanitized local captures confirm the layout at mobile/tablet/desktop widths. ## Validation - Six Chromium scenarios pass against HTTPS, real PostgreSQL and TLS SMTP. - API/web lint, typecheck and production builds pass; 103 API and 51 Angular unit tests pass. - Go tests, `buf lint`, formatting, diff checks and gitleaks commit hooks pass. - API integration: all 84 tests across 19 files pass on disposable PostgreSQL databases. ## Security considerations No backend authorization, throttling, audit or credential policy is weakened. Fault injection operates at the browser transport around actual committed requests; backend services remain real. Browser time advances only to verify temporary-display expiry, without changing server time. Assertions compare booleans/counts or hashes rather than printing private grants, and private fill failures remain opaque. Tests create no traces, HAR files or screenshots. No new dependency. M2.2e4b is complete. Manual visual/accessibility inspection, independent finish review and design-system documentation remain in M2.2e4c; this PR does not claim full WCAG conformance or completion of M2.2 as a whole. CodeQL remains skipped by the repository workflow; enabled CI checks are reported below. ## Checklist - [x] M2.2e4b2 criteria covered and PLAN updated - [x] Lint, TS tests, Go tests and `buf lint` pass locally - [x] Regression tests exercise the retry bug and recovery-code overflow - [x] No new shell invocation or secret exposure path - [x] Existing audited command paths exercised without modification - [x] Retry semantics and test coverage documented in SPEC/README
4 of 5 tasks
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
…94) ## Task Review follow-up for #73 (M2.2e4b1). Refs #21 ## What changed - `apps/api/src/testing/postgres-image.ts` exports `POSTGRES_TEST_IMAGE`, the same digest-pinned `postgres:17@sha256:3b0cda93…` used by the CI service container and `deploy/dev/compose.yml`. - The eight Testcontainers call sites (browser/integration app helper and seven integration specs) use it instead of the mutable `postgres:17` tag. - A unit test asserts the constant is digest-pinned and identical to the reference in `.github/workflows/ci.yml` and `deploy/dev/compose.yml`, so the three cannot drift. ## Why THREAT_MODEL requires every tool image to be pinned to a digest. The browser acceptance job and local integration runs pulled `postgres:17` by tag, which a retagged or compromised upstream image could replace. ## How it was tested - `nx run-many -t lint typecheck test -p api` in a clean worktree: 22 files, 105 tests pass, lint and typecheck clean. - Integration and browser jobs could not run: GitHub Actions is currently blocked by the account spending limit, and Docker is not available in the local sandbox. CI must pass before merge. ## Security considerations Supply-chain hardening of test infrastructure only. No runtime change. ## Checklist - [x] Lint, TS tests pass locally - [x] Test added (pin consistency) - [x] No new shell invocation and no new secret exposure path - [x] Audit events: not applicable - [ ] CI green (blocked by billing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
[M2.2e4b1] Real-browser identity acceptance. Stacked on #72; review the prerequisite stack before merging. No merge requested.
What changed and why
The production Angular build normalizes
ngCspNonceto lowercase and copies its placeholder onto generated script/style tags. The server previously rejected that real build at startup. Accept the normalized attribute and replace every placeholder with the same fresh per-response nonce; retain strict CSP and add a focused HTTP regression test.Add
pnpm test:browserand a CI job running pinned Chromium against production assets and a real Nest API, disposable PostgreSQL, and local TLS SMTP. The suite covers all six public forms, signup → delivered verification code → login → logout, secure session/CSRF cookies, missing-CSRF and foreign-Origin rejection, empty browser storage, secret-free navigation URLs, strict CSP execution, error focus, automated WCAG rules, and horizontal overflow at 320/390/768/1024/1440 pixels. Account security receives an automated accessibility check after login.How it was tested
buf lint, formatting andgit diff --checkpass.Security considerations
The browser fixture always creates its own database, including when a developer
DATABASE_URLis inherited. It restores overridden environment values, shuts down resources in reverse order and sends mail only to the loopback TLS fixture. Self-signed HTTPS acceptance is confined to the isolated browser context. Browser requests to other origins are blocked. No traces, HAR files or screenshots are recorded; private fill failures and accessibility assertions avoid serializing credentials. No new product mutation or audit path is introduced.Development-only dependencies: Playwright 1.64.1 (Apache-2.0) and @axe-core/playwright 4.14.0 (MPL-2.0), pinned in manifests and lockfile.
Password-reset, MFA/recovery and token-management browser workflows, failure/retry/private-grant checks, manual visual/accessibility inspection and design documentation remain explicitly unchecked in PLAN M2.2e4b2/M2.2e4c. Automated accessibility checks do not establish full WCAG conformance. This is the final PR in the current work session, as requested.
Checklist
buf lintpass locally