Skip to content

Resolves issue #1870, hardens auth context helpers so unauthenticated requests cannot use unvalidated requester header context for identity or role decisions.#1897

Merged
jdaigneau5 merged 2 commits into
devfrom
dr_1870
Jul 1, 2026
Merged

Resolves issue #1870, hardens auth context helpers so unauthenticated requests cannot use unvalidated requester header context for identity or role decisions.#1897
jdaigneau5 merged 2 commits into
devfrom
dr_1870

Conversation

@david-rocca

Copy link
Copy Markdown
Collaborator

Closes Issue #1870

Summary

This change distinguishes between requests where authentication has not been evaluated and requests where authentication was evaluated and failed. Once authentication has failed, auth-context helpers no longer fall back to raw req.ctx.org or req.ctx.user values when resolving requester organization, requester user, UUIDs, Secretariat status, bulk-download status, admin status, or admin-of-org status.

Important Changes

src/middleware/middleware.js

  • Added req.ctx.authenticationChecked.
  • Set the flag in both required and optional authentication middleware after auth evaluation succeeds or fails.

src/utils/authContext.js

  • Added a helper for detecting unauthenticated requests after an auth check.
  • Prevented raw requester header fallback for unauthenticated-after-check requests.
  • Preserved trusted UUID-based internal context behavior.

test/unit-tests/utils/authContextTest.js

  • Added unit coverage for unauthenticated fallback blocking.
  • Added coverage for trusted internal UUID context and authenticated UUID context.

test/integration-tests/cve-id/getCveIdTest.js

  • Added an integration regression for invalid credentials on an optionally authenticated endpoint.

@david-rocca david-rocca linked an issue Jun 30, 2026 that may be closed by this pull request
@jdaigneau5 jdaigneau5 merged commit 0800b18 into dev Jul 1, 2026
9 checks passed
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.

authContext.js uses req.ctx.org from unauthenticated request

2 participants