Repository navigation
fix: refuse HMAC mint when API auth is unset - #28
Draft
cursor[bot] wants to merge 1 commit into
Draft
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Reviewer's GuidePrevents an unauthenticated HMAC signing oracle by requiring API authentication whenever Sequence diagram for authenticated HMAC approval mintingsequenceDiagram
participant Client
participant Flask as serve.py
participant Auth as _api_key()
participant Tokens as mint_token()
Client->>Flask: POST /api/approve/mint
Flask->>Flask: hmac_configured()
alt HMAC key unset
Flask-->>Client: 503 HMAC minting refused
else HMAC key configured
Flask->>Auth: _api_key()
alt API key unset
Flask-->>Client: 503 unauthenticated HMAC mint refused
else API key configured
Flask->>Flask: _guard_api()
alt X-Aegis-Key missing or invalid
Flask-->>Client: 401 unauthorized
else API key valid
Flask->>Tokens: mint_token()
Tokens-->>Flask: bound HMAC token
Flask-->>Client: 200 token
end
end
end
Flow diagram for HMAC authentication startup enforcementflowchart TD
A[Server import] --> B["_load_signer()"]
B --> C["load_approve_key()"]
C --> D["_require_api_key_for_hmac()"]
D --> E{"hmac_configured() and no _api_key()?"}
E -->|Yes| F[SystemExit]
E -->|No| G[Start server]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
AEGIS_APPROVE_KEY without AEGIS_API_KEY left POST /api/approve/mint open as a signing oracle: anyone who could reach the port could mint valid G2/G3 tokens for any bundle hash. Match the existing seal-key gate — SystemExit at start and 503 on mint. Co-authored-by: georgy75 <georgy75@gmail.com>
cursor
Bot
force-pushed
the
cursor/critical-bug-management-9673
branch
from
September 5, 2026 03:30
ed2e547 to
76db585
Compare
This branch has not been deployed
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.
Bug and impact
When
AEGIS_APPROVE_KEYis set butAEGIS_API_KEYis not,POST /api/approve/mintis an unauthenticated HMAC signing oracle. Anyone who can reach the port can mint a valid G2/G3 token for any bundle hash, thenPOST /api/preflight/promotewith that token. The promotion record storesmethod=hmac-sha256as if a real approver signed it.Pinned
AEGIS_SEAL_KEYalready refuses to start without API auth. HMAC mint was the same class of hole and was not gated.Root cause
T1 #9/#10 added HMAC tokens and
X-Aegis-Key, plusSystemExitfor a pinned seal key without an API key. The mint route only required the HMAC key to be configured._guard_api()is a no-op whenAEGIS_API_KEYis unset, so the signing endpoint stayed open.Fix
SystemExitat startup ifAEGIS_APPROVE_KEYis set andAEGIS_API_KEYis not (same pattern as seals).503on mint if HMAC is configured after import without API auth (env is read live).X-Aegis-Keyis 401; bound mint+promote still works when both keys are set.Validation
python -m aegis.tests.api_test— 45 checks PASSpython -m aegis.tests.tokens_test— 17 checks PASSpython -m aegis.tests.promote_test 200— PASS (HMAC random refused, bound token ok)Summary by Sourcery
Require API authentication for HMAC approval minting to prevent unauthenticated token issuance.
Bug Fixes:
Enhancements:
Documentation:
Tests: