sec: resolve cryptographic timing attack vulnerability in admin authentication (#18)#21
Conversation
Add a .env.example with LLM API placeholders and optional overrides to document environment variables. Add a project-level humane_proxy.yaml containing server, safety, heuristics, trajectory, and escalation default settings. Improve admin auth by importing hmac and using hmac.compare_digest for token comparison to avoid timing-attack risk.
|
|
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis PR introduces environmental configuration and security improvements for HumaneProxy. It adds an environment template file, hardens admin token validation with constant-time comparison to prevent timing attacks, and establishes a comprehensive runtime configuration file defining safety thresholds, keyword heuristics for content filtering, context reduction rules, and escalation/alerting settings. ChangesConfiguration and Security Updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@humane_proxy/humane_proxy.yaml`:
- Line 3: Replace the placeholder documentation URL
"https://github.com/your-org/humane-proxy#configuration" in the comment at the
top of humane_proxy.yaml with the real repository or docs path for this project
(e.g., your org's actual GitHub repo or the project's docs site) so users
following the configuration link land on a working page; update the comment
string to the correct URL.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1bcf5ca4-e01a-4f0e-ae50-a006345f3669
📒 Files selected for processing (3)
humane_proxy/.env.examplehumane_proxy/api/admin.pyhumane_proxy/humane_proxy.yaml
|
@rishabh0510rishabh |
|
@rishabh0510rishabh I require you to sign the CLA and explain the commit at the earliest. |
|
Hi @Vishisht16,
I apologize for the late response. My exams are currently ongoing, so I
haven't been able to commit much time to this lately.
I will be free after May 20th, at which point I will look into the issue
and, get back to you with an explanation and the necessary updates as soon
as possible
…On Mon, 18 May, 2026, 21:49 Vishisht Mishra, ***@***.***> wrote:
*Vishisht16* left a comment (Vishisht16/Humane-Proxy#21)
<#21 (comment)>
@rishabh0510rishabh <https://github.com/rishabh0510rishabh> I require you
to sign the CLA and explain the commit at the earliest.
—
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AULY2H6HHYBGJC2AMRLWWWD43MZ25AVCNFSM6AAAAACZBGVFDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DINZZGYZDQMBSGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@rishabh0510rishabh |
|
I think it may have happened when I was running local tests and copied them
into the humane_proxy/ subdirectory to solve a relative path config issue,
then staged them
…On Mon, 18 May, 2026, 21:57 Vishisht Mishra, ***@***.***> wrote:
*Vishisht16* left a comment (Vishisht16/Humane-Proxy#21)
<#21 (comment)>
@rishabh0510rishabh <https://github.com/rishabh0510rishabh>
If you could write this comment, I need a one liner explanation to my
question as soon as possible.
—
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AULY2H4HYG7AIBEVMJYR7DD43M2YNAVCNFSM6AAAAACZBGVFDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DINZZGY4DONBZGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@rishabh0510rishabh I'll merge it once you sign the CLA. |
|
Also, it's a good practice to check staged files before you commit. You as another maintainer should know that. |
PR Description
Problem / Motivation
Analysis of the REST Admin API middleware revealed a critical timing side-channel security vulnerability in how Bearer tokens are validated.
In
humane_proxy/api/admin.py's_require_admindependency, theHUMANE_PROXY_ADMIN_KEYextracted from the environment was compared against the incoming request credentials using Python's standard inequality operator (!=).Because standard string equality compares strings character-by-character and short-circuits upon encountering the first mismatch, it introduces a measurable timing discrepancy based on how many characters of the client's payload match the actual secret. An attacker can leverage this timing side-channel (CWE-208) to brute-force the
HUMANE_PROXY_ADMIN_KEYover the network, thereby granting them full access to all/adminendpoints (such as exporting or deleting sensitive escalation records).Proposed Fix
This PR replaces the short-circuiting inequality operator (
!=) withhmac.compare_digestfrom the Python standard library.hmac.compare_digestis specifically designed for cryptographic constant-time comparison. It performs a uniform, constant-time comparison of the two string values regardless of whether, or where, the characters mismatch. This entirely closes the timing side-channel vulnerability.Technical Changes
We imported the
hmacmodule and updated_require_adminin admin.py:Verification & Testing
All tests have been run locally to ensure correctness and that no regressions are introduced.
401 Unauthorized/403 Forbiddenstatus codes.python -m pytest ..\tests214 passed, 13 skipped(0 failures).Compliance and Checklist
hmac.compare_digest) for constant-time comparison