Remove Hardcoded OAuth Secret, Enforce JWT Secret Validation, and Add Challenge Expiry/Rate Limiting - #74
Open
mertcano wants to merge 1 commit into
Open
Remove Hardcoded OAuth Secret, Enforce JWT Secret Validation, and Add Challenge Expiry/Rate Limiting#74mertcano wants to merge 1 commit into
mertcano wants to merge 1 commit into
Conversation
… Challenge Expiry/Rate Limiting ### Description This pull request addresses critical and high-severity security vulnerabilities identified in `task-master` during the Quantus workspace security audit (**FM-01, FM-02, FM-03**)[cite: 54]. A live X (Twitter) OAuth client secret was previously committed in plaintext within `default.toml`, creating an immediate credential exposure risk[cite: 54]. Additionally, the server could start using committed placeholder JWT secrets, allowing arbitrary token forgery[cite: 54]. Furthermore, the unauthenticated `request-challenge` endpoint was susceptible to unbounded memory growth (DoS) and authentication replay attacks due to missing TTLs and capacity bounds[cite: 54]. ### Key Changes & Remediations #### 1. OAuth Secret Redaction (FM-01 - `config/default.toml`) * **Redacted Credentials:** Replaced the committed live X OAuth credentials with explicit `"replace-me"` placeholders[cite: 54, 55]. * **Operator Documentation:** Added explicit security comments requiring credentials to be injected via environment-specific configuration[cite: 55]. *(Note: Maintainers must rotate the compromised secret with X and purge historical git references)[cite: 54].* #### 2. Fail-Fast JWT Secret Validation (FM-02 - `src/config.rs`) * **Placeholder Detection:** Added `validate()` to `Config::load()`, checking whether `jwt.secret` or `jwt.admin_secret` equals `"this-should-be-overriden"`[cite: 54, 56]. * **Server Boot Refusal:** Halts process startup with an actionable `ConfigError` instructing operators to set `TASKMASTER_JWT__SECRET` and `TASKMASTER_JWT__ADMIN_SECRET` rather than running with known signing keys[cite: 54, 56]. #### 3. Challenge Memory Capping & Replay Protection (FM-03 - `src/handlers/auth.rs`, `src/http_server.rs`) * **TTL & Capacity Limits:** Defined `Challenge::TTL_SECONDS = 300` and `Challenge::MAX_PENDING = 10_000`[cite: 54, 58]. * **Eviction & Back-Pressure:** In `request_challenge`, expired entries are pruned via `retain()`[cite: 54, 57]. If pending challenges still exceed `MAX_PENDING`, the handler responds with `StatusCode::TOO_MANY_REQUESTS`[cite: 54, 57]. * **Replay Mitigation:** `verify_login` validates expiration via `is_expired(Utc::now())` and removes consumed or expired challenges from the store[cite: 54, 57]. ### How to Review 1. Inspect `config/default.toml` to verify that no live credentials remain[cite: 55]. 2. Review `src/config.rs` to confirm `Config::validate()` properly errors out when default JWT placeholders are used[cite: 56]. 3. Inspect `src/handlers/auth.rs` and `src/http_server.rs` to verify challenge eviction logic, the `MAX_PENDING` check, and single-use replay deletion[cite: 57, 58].
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.
Description
This pull request addresses critical and high-severity security vulnerabilities identified in
task-masterduring the Quantus workspace security audit (FM-01, FM-02, FM-03)[cite: 54].A live X (Twitter) OAuth client secret was previously committed in plaintext within
default.toml, creating an immediate credential exposure risk[cite: 54]. Additionally, the server could start using committed placeholder JWT secrets, allowing arbitrary token forgery[cite: 54]. Furthermore, the unauthenticatedrequest-challengeendpoint was susceptible to unbounded memory growth (DoS) and authentication replay attacks due to missing TTLs and capacity bounds[cite: 54].Key Changes & Remediations
1. OAuth Secret Redaction (FM-01 -
config/default.toml)"replace-me"placeholders[cite: 54, 55].2. Fail-Fast JWT Secret Validation (FM-02 -
src/config.rs)validate()toConfig::load(), checking whetherjwt.secretorjwt.admin_secretequals"this-should-be-overriden"[cite: 54, 56].ConfigErrorinstructing operators to setTASKMASTER_JWT__SECRETandTASKMASTER_JWT__ADMIN_SECRETrather than running with known signing keys[cite: 54, 56].3. Challenge Memory Capping & Replay Protection (FM-03 -
src/handlers/auth.rs,src/http_server.rs)Challenge::TTL_SECONDS = 300andChallenge::MAX_PENDING = 10_000[cite: 54, 58].request_challenge, expired entries are pruned viaretain()[cite: 54, 57]. If pending challenges still exceedMAX_PENDING, the handler responds withStatusCode::TOO_MANY_REQUESTS[cite: 54, 57].verify_loginvalidates expiration viais_expired(Utc::now())and removes consumed or expired challenges from the store[cite: 54, 57].How to Review
config/default.tomlto verify that no live credentials remain[cite: 55].src/config.rsto confirmConfig::validate()properly errors out when default JWT placeholders are used[cite: 56].src/handlers/auth.rsandsrc/http_server.rsto verify challenge eviction logic, theMAX_PENDINGcheck, and single-use replay deletion[cite: 57, 58].