Skip to content

Define confidential vulnerability remediation process and harden REST API token comparison - #2144

Merged
josecelano merged 12 commits into
torrust:developfrom
josecelano:security/private-remediation-20260904
Sep 4, 2026
Merged

josecelano merged 12 commits into
torrust:developfrom
josecelano:security/private-remediation-20260904

Conversation

@josecelano

Copy link
Copy Markdown
Member

Closes #2142
Closes #2143

Summary

This PR does two things that were deliberately developed together on a private branch and are disclosed together:

  1. Defines the confidential vulnerability remediation process (Define the confidential vulnerability remediation process #2142) — the maintainer-side workflow for reports received through the channel in SECURITY.md, which the repository did not have. It includes a confidentiality boundary, mandatory independent reproduction, maintainer-set severity, vetting of reporter-suggested fixes and dependencies as untrusted input, an explicit disclosure-path decision, a handled-report catalog so a processed finding is never re-triaged, and guards on the existing public CVE workflows so they no longer instruct opening public issues for embargoed reports.

  2. Applies it for the first time (Use constant-time comparison for REST API access tokens #2143) — a constant-time comparison for REST API access tokens.

Classification of #2143

Low-severity hardening (CWE-208 class). Not a confirmed vulnerability. No CVE, no security advisory.

The REST API middleware compared the supplied token against configured tokens with plain == inside Iterator::any, which may exit early. Independent reproduction on x86-64/glibc found no observable position-dependent timing (glibc's memcmp uses wide SIMD compares for inputs of this size); evidence is in docs/issues/open/2143-rest-api-constant-time-token-comparison/reproduction.md. The comparison nevertheless had no constant-time contract, so authenticate now folds subtle::ConstantTimeEq over all configured tokens. subtle was already in Cargo.lock at the same checksum via sqlx; no new code enters the binary.

No user action is required. As always, bind the REST API to a private interface or place it behind a reverse proxy.

What the first case taught the process

The remediation was initially implemented on the reporter's suggested crate before reproduction or dependency vetting. That was caught in review and is now recorded honestly in the spec; the three mandatory triage sub-steps in docs/security/vulnerability-remediation.md exist because of it. The handle-secrets skill now requires constant-time comparison for secrets so the rule outlives this specific record.

Also included

  • docs/security/analysis/production/RUSTSEC-2023-0071.md — the pre-existing rsa Marvin advisory surfaced during dependency vetting, cataloged as non-affecting (tracker only performs public-key encryption to its own MySQL).
  • docs/templates/SECURITY-REPORT.md and docs/security/analysis/reports/ — the handled-report catalog with its first record.

Verification

  • cargo test -p torrust-tracker-axum-rest-api-server: 3 new unit tests + 58 contract tests pass.
  • Manual: valid bearer and query tokens return 200; same-length wrong token returns 500 token not valid.
  • Full pre-commit gate (cargo machete, cargo deny check bans, linter all, hadolint, doc tests) passes on every commit.

Credit

Reported by Abdurazzoqov Javohir (@abdurazzoqovjavohir700-dev) via source review through the coordinated-disclosure channel. Thank you. The fix commit carries a Reported-by: trailer.

Review notes

Commits are separated by concern (process, specs, triage amendment, advisory catalog, fix, report catalog, report record, issue metadata) and can be read independently. Out of scope and deliberately not bundled: REST API rate limiting, token-length leakage, and the ?token= query-string path.

Copilot AI lite review requested due to automatic review settings September 4, 2026 17:13
@josecelano
josecelano requested a review from a team as a code owner September 4, 2026 17:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The security hardening and new documentation workflow appear correct and consistent; only a minor test-naming nit was identified.

Pull request overview

This PR adds a repository-owned, confidentiality-preserving workflow for handling coordinated-disclosure security reports, and applies it immediately to harden REST API access-token verification by switching to a constant-time comparison contract.

Changes:

  • Documented a confidential vulnerability remediation process, including disclosure-path decisions and strict “don’t publish before disclosure” boundaries.
  • Added a handled-report catalog + template for sanitized post-disclosure records, and updated existing public CVE workflows/skills to avoid leaking embargoed reports.
  • Hardened REST API token comparison using subtle::ConstantTimeEq across all configured tokens, with new unit tests and a direct subtle dependency.
File summaries
File Description
SECURITY.md Links the public security policy to the new confidential remediation process.
project-words.txt Adds security/reporting-related terms and reporter name/handle to spellcheck allowlist.
packages/axum-rest-api-server/src/v1/middlewares/auth.rs Implements constant-time token comparison across all configured tokens; adds unit tests.
packages/axum-rest-api-server/Cargo.toml Adds direct subtle dependency for constant-time comparisons.
Cargo.lock Records subtle as a direct dependency of the REST API server crate.
docs/security/vulnerability-remediation.md New canonical maintainer process for confidential coordinated-disclosure handling.
docs/security/README.md Documents the handled-report catalog and links to the remediation process.
docs/security/analysis/README.md Guards the public analysis workflow against embargoed/coordinated-disclosure reports; documents reports/.
docs/security/analysis/reports/README.md Defines rules, template usage, and index for handled coordinated-disclosure reports.
docs/templates/SECURITY-REPORT.md Adds a template for sanitized handled-report records.
docs/security/analysis/reports/2026-09-04_rest-api-token-timing.md First handled-report record documenting the token timing hardening and rationale.
docs/security/analysis/production/RUSTSEC-2023-0071.md Catalogs a pre-existing advisory as non-affecting, to prevent repeated re-triage.
docs/issues/open/2142-define-confidential-vulnerability-remediation-process/ISSUE.md Spec documenting goals/scope/verification for the new confidential remediation process.
docs/issues/open/2143-rest-api-constant-time-token-comparison/ISSUE.md Spec documenting rationale, triage evidence, and implementation plan for constant-time token comparison.
docs/issues/open/2143-rest-api-constant-time-token-comparison/reproduction.md Evidence artifact recording the (negative) independent timing reproduction attempt.
docs/index.md Adds the SECURITY-REPORT template to the docs index.
.github/skills/dev/rust-code-quality/handle-secrets/SKILL.md Adds a durable rule and example for constant-time secret comparison using subtle.
.github/skills/dev/maintenance/catalog-security-vulnerabilities/SKILL.md Clarifies this workflow is only for public/approved findings; points to confidential remediation otherwise.
.github/skills/dev/maintenance/run-manual-docker-security-scan/SKILL.md Adds an explicit embargo/public-disclosure guard before opening public issues/docs.
Review details
  • Files reviewed: 18/19 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.38%. Comparing base (9658f3e) to head (5feafac).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2144      +/-   ##
===========================================
+ Coverage    84.35%   84.38%   +0.02%     
===========================================
  Files          351      351              
  Lines        28336    28357      +21     
  Branches     28336    28357      +21     
===========================================
+ Hits         23904    23930      +26     
+ Misses        4031     4027       -4     
+ Partials       401      400       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano

Copy link
Copy Markdown
Member Author

ACK 5feafac

@josecelano
josecelano merged commit 2d4a98d into torrust:develop Sep 4, 2026
18 checks passed
josecelano added a commit that referenced this pull request Sep 6, 2026
27f4fff chore(issues): archive closed issue specs #2142 and #2143 (Jose Celano)

Pull request description:

  Related to #2142
  Related to #2143

  Archives the specifications for the two issues closed automatically when PR #2144 merged.

  - Verified both GitHub issues are `CLOSED`.
  - Moved both folder-style specifications and the timing-reproduction evidence from `docs/issues/open/` to `docs/issues/closed/`.
  - Updated frontmatter (`status: done`, `spec-path`, and closure timestamp), completed closure checkpoints, and added merge/archive evidence.
  - Updated the handled-report record to point to the archived security-hardening specification.
  - Checked for stale `docs/issues/open/2142-...` and `2143-...` references; none remain.
  - `linter all` and the full pre-commit gate pass.

ACKs for top commit:
  josecelano:
    ACK 27f4fff

Tree-SHA512: ecbf4e5c1d97a238a1c11fbac628ca16976d093c48a6249a00c607321539273bbe816b16cad5a71f516441e7d897fef2c2dd2332df95ad20bc107504b922f203

@da2ce7 da2ce7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-merge review of #2144 as the change stands at f72f93c5c on the default branch.

What still runs: authenticate at packages/axum-rest-api-server/src/v1/middlewares/auth.rs:160 is the function from 90d7a63, unchanged apart from its position in the file. It ORs subtle::ConstantTimeEq::ct_eq over every configured token and converts the Choice to bool only after the fold, and subtle = "2.6.1" remains a direct dependency at packages/axum-rest-api-server/Cargo.toml:48. The unit tests added with it have since been rewritten as middleware-level cases, afe91f5 turned a non-ASCII Authorization header into a rejection instead of a fall-back to the query token, and #3042 took the token out of the request log. The process text added to SECURITY.md and docs/security/vulnerability-remediation.md is unchanged.

[Minor] A hardening gap that predates #2144 and survives the hardened comparison: an empty supplied token authenticates whenever one of the configured access tokens is empty. An Authorization header holding the Bearer scheme with no token after it becomes an empty token (packages/axum-rest-api-server/src/v1/middlewares/auth.rs:117-119, and through the strip_prefix at auth.rs:127-129 when only a space follows), an empty token query parameter does too, and ct_eq of two empty slices is true, so authenticate (auth.rs:160-168) admits the request to every route behind the middleware. Nothing refuses the empty value when the configuration loads: access_tokens at packages/configuration/src/v3_0_0/tracker_api.rs:39 is a plain map of SecretString, whereas an empty network database password is refused at packages/configuration/src/v3_0_0/database.rs:210. No shipped configuration carries an empty token and the API is off by default, so the exposure is limited to an operator configuration that leaves a token empty, but there the outcome is a silent fail-open rather than a startup error. The existing cases check an empty supplied token only against non-empty configured tokens. Smallest fix: return false from authenticate when the supplied token is empty (a zero length discloses nothing about the configured tokens) and add a case that configures an empty token; refusing empty token values when the configuration loads, as the database password already is, closes it at the source.

[Nit] The doc comment at packages/axum-rest-api-server/src/v1/middlewares/auth.rs:153 says the check runs "without content-dependent early exits", but ct_eq on slices returns at once when the lengths differ, so the work still depends on which configured tokens share the supplied token's length. The issue spec and the handled-report record accept token-length leakage as out of scope; the comment that warns against simplifying to == is the text an editor of this function reads, and it does not say so. Smallest fix: one sentence in that comment stating that token length is not hidden.

Checked and found sound: the fold evaluates every configured token with no branch on a comparison result, each Choice passes through the crate's optimisation barrier, and an empty token map fails closed; header-over-query precedence and the rejection of a duplicated token parameter match the tests; subtle 2.6.1 was already resolved at the same checksum before #2144 (through rsa and digest under sqlx-mysql, and through rustls), so the description's dependency claim holds, and 90d7a63 is reachable from the tip; the paths the process document relies on (docs/security/analysis/reports/, docs/templates/SECURITY-REPORT.md, docs/issues/drafts/ and the ignored .tmp/ directory) exist at the tip, and the link from SECURITY.md resolves.

This branch was previously deployed

1 inactive deployment
coverage — 5feafac5 Deployed Sep 4, 2026 by josecelano via Generate Coverage Report #1919
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.

Use constant-time comparison for REST API access tokens Define the confidential vulnerability remediation process

3 participants