security: send lock_id via X-CacheKit-Lock-Id header, not query string (#131)#179
Conversation
#131) The distributed-lock capability token was sent as ?lock_id= on the unlock DELETE. Query strings are captured by access/proxy logs and OpenTelemetry http.url spans (CWE-532), letting anyone with log access replay the token to release a lock within its ~30s TTL. _release_lock now sends the token in the X-CacheKit-Lock-Id request header and drops it from the URL. The SaaS handler dual-reads header + legacy ?lock_id= (deployed in saas 0.1.7), so this is wire-compatible with prod. Ratified in protocol spec/saas-api.md. Tests updated: the URL-injection cases now assert the token is isolated in the header and never touches the URL; added a positive header-transport assertion. SECURITY.md documents the transport.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis pull request relocates the distributed-lock token ( ChangesLock Token Header Protocol
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Closes #131.
The distributed-lock capability token was sent as
?lock_id=on the unlockDELETE. Query strings are routinely captured by access/proxy logs and OpenTelemetryhttp.urlspans (CWE-532), letting anyone with log access replay the token to release a lock within its ~30s TTL.Change
CachekitIOBackend._release_locknow sends the token in theX-CacheKit-Lock-Idrequest header and drops it from the URL. New module constantLOCK_ID_HEADER.Wire compatibility
The SaaS unlock handler dual-reads the header + legacy
?lock_id=query (prefers header), shipped in saas#140 / deployed in0.1.7. So this flip is compatible with liveapi.cachekit.io. Ratified in protocolspec/saas-api.md(the query param is removed in protocol 2.0).Tests
X-CacheKit-Lock-Idcarries the exact token).SECURITY.mddocuments the transport.Part of the cross-SDK #131 rollout (ts#63 / rs#24 to follow).
Summary by CodeRabbit
Release Notes
Security Fixes
Documentation