Skip to content

Commit 86fdb2b

Browse files
committed
fix: backport stack-auth token-refresh fix (CIP-3159)
Access-key auth on 2.2.2 saw ZeroKMS "Request not authorized" begin ~15 min (the access-token lifetime) after startup. A get_token() future cancelled in the post-HTTP, pre-install window of stack-auth's AutoRefresh::refresh_non_blocking defused its CancelGuard too early, stranding refresh_in_progress = true. Every later refresh then wedged; once the cached token crossed real expiry, callers hung in wait_for_in_flight_refresh forever. The upstream fix (move defuse() after the token install + flag clear) first ships in stack-auth >= 0.36.0, but bumping cipherstash-client to that line drags in an unrelated EQL API redesign. Instead, vendor the published stack-auth 0.34.1-alpha.4 source, apply the CancelGuard reordering, and override the transitive dependency via [patch.crates-io] (same version satisfies cipherstash-client's exact pin, so no republish). Includes a regression test that fails on the pre-fix ordering. Remove the patch once Proxy moves to cipherstash-client built against stack-auth >= 0.36.0.
1 parent bdeead3 commit 86fdb2b

29 files changed

Lines changed: 10414 additions & 2 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- **ZeroKMS authentication failures ~15 minutes after startup**: Fixed a token-refresh wedge in the access-key authentication path. When an in-flight request was cancelled at the wrong moment (for example, a client disconnecting mid-query), token refresh could permanently stall, causing `ZeroKMS error: Request not authorized` on all encrypt/decrypt operations roughly 15 minutes (the access-token lifetime) after connecting. Connections worked on startup and then began failing in lockstep. Backports the upstream `stack-auth` token-refresh fix (CIP-3159).
12+
913
## [2.2.2] - 2026-06-01
1014

1115
### Fixed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[workspace]
22
resolver = "2"
33
members = ["packages/*"]
4+
# Vendored crate is consumed only via [patch.crates-io] below, not as a member.
5+
exclude = ["vendor/stack-auth"]
46

57
[workspace.package]
68
version = "2.2.2"
@@ -56,3 +58,13 @@ tracing-subscriber = { version = "^0.3.20", features = [
5658
"env-filter",
5759
"std",
5860
] }
61+
62+
# HOTFIX (CIP-3159): backport the stack-auth token-refresh CancelGuard fix onto
63+
# the 0.34.1-alpha.4 source that cipherstash-client 0.34.1-alpha.4 pins. Without
64+
# this, a cancelled get_token() future could strand `refresh_in_progress = true`,
65+
# wedging all later refreshes and causing ZeroKMS "Request not authorized" exactly
66+
# ~15 min (token TTL) after startup. The patch keeps version 0.34.1-alpha.4 so it
67+
# satisfies cipherstash-client's exact pin while replacing the registry source.
68+
# Remove once Proxy moves to a cipherstash-client built against stack-auth >= 0.36.0.
69+
[patch.crates-io]
70+
stack-auth = { path = "vendor/stack-auth" }

vendor/stack-auth/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

vendor/stack-auth/CHANGELOG.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
2+
3+
4+
### Miscellaneous
5+
6+
- release v0.34.1-alpha.2
7+
8+
9+
### Miscellaneous
10+
11+
- release
12+
- use explicit versions for cipherstash-client and stack-auth
13+
14+
15+
### Miscellaneous
16+
17+
- updated the following local packages: cts-common, cts-common, stack-profile, zerokms-protocol
18+
19+
20+
### Documentation
21+
22+
- 📝 add TypeScript example for AutoStrategy usage
23+
- 📝 add CHANGELOG.md for @cipherstash/auth
24+
- 📝 add INVALID_CRN to changelog error codes
25+
- 📝 demonstrate whoami (subject/workspace) in examples
26+
- 📝 update CHANGELOG with whoami fields and security notes
27+
28+
### Features
29+
30+
- ✨ expose auth strategies in @cipherstash/auth Node bindings
31+
- ✨ add subject() and workspace_id() to ServiceToken
32+
- add multi-workspace profile support (CIP-2942)
33+
- require workspace to exist before switching
34+
35+
### Fixes
36+
37+
- 🩹 add INVALID_CRN error code and deduplicate zerokms_url
38+
- 🔒️ derive OpaqueDebug on TokenResult to prevent token leaks
39+
- 🔒️ derive OpaqueDebug on AutoStrategyOptions
40+
- update integration tests for workspace-scoped profiles
41+
- hard-error on token persistence failure, strengthen test assertions
42+
- use npm install instead of npm ci in integration test tasks
43+
44+
### Miscellaneous
45+
46+
- 🔖 bump @cipherstash/auth to 0.35.0
47+
- 🔧 regenerate index.d.ts from napi build
48+
- release
49+
50+
### Refactoring
51+
52+
- ♻️ restructure stack-auth-node tests to follow conventions
53+
- simplify workspace store usage
54+
55+
### Testing
56+
57+
- ✅ add unit tests for exposed auth strategies
58+
59+
### Style
60+
61+
- 💄 fix cargo fmt formatting
62+
- 🎨 remove redundant comments from examples
63+
64+
65+
### Documentation
66+
67+
- 📝 add TypeScript example for AutoStrategy usage
68+
- 📝 add CHANGELOG.md for @cipherstash/auth
69+
- 📝 add INVALID_CRN to changelog error codes
70+
- 📝 demonstrate whoami (subject/workspace) in examples
71+
- 📝 update CHANGELOG with whoami fields and security notes
72+
73+
### Features
74+
75+
- ✨ expose auth strategies in @cipherstash/auth Node bindings
76+
- ✨ add subject() and workspace_id() to ServiceToken
77+
78+
### Fixes
79+
80+
- 🩹 add INVALID_CRN error code and deduplicate zerokms_url
81+
- 🔒️ derive OpaqueDebug on TokenResult to prevent token leaks
82+
- 🔒️ derive OpaqueDebug on AutoStrategyOptions
83+
84+
### Miscellaneous
85+
86+
- 🔖 bump @cipherstash/auth to 0.35.0
87+
- 🔧 regenerate index.d.ts from napi build
88+
89+
### Refactoring
90+
91+
- ♻️ restructure stack-auth-node tests to follow conventions
92+
93+
### Testing
94+
95+
- ✅ add unit tests for exposed auth strategies
96+
97+
### Style
98+
99+
- 💄 fix cargo fmt formatting
100+
- 🎨 remove redundant comments from examples
101+
# Changelog
102+
103+
All notable changes to this project will be documented in this file.
104+
105+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
106+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
107+
108+
### Features
109+
110+
- add provisionDeviceClient Node.js binding and tests
111+
112+
### Fixes
113+
114+
- lock file
115+
- add User-Agent header, rename to device_client, surface errors
116+
117+
### Miscellaneous
118+
119+
- clean up test imports and simplify mise task
120+
121+
### Refactoring
122+
123+
- extract device client provisioning from CLI into stack-auth
124+
- rename provisionDeviceClient to bindClientDevice
125+
126+
127+
### Documentation
128+
129+
- add README for stack-auth and include it as module docs
130+
- add README for @cipherstash/auth npm package
131+
132+
### Fixes
133+
134+
- remove blank line to satisfy cargo fmt
135+
- update vitaminc imports for 0.1.0-pre4.2 module restructure
136+
137+
138+
### Documentation
139+
140+
- 📝 move token refresh docs and mermaid diagram to public AuthStrategy trait
141+
142+
### Fixes
143+
144+
- 🐛 fix race condition in get_token() when token expires during refresh
145+
146+
### Testing
147+
148+
- ✅ restructure auto_refresh tests into nested scenario modules
149+
150+
151+
### Documentation
152+
153+
- 📝 fix AutoStrategy docs to reference CS_WORKSPACE_CRN not CS_REGION
154+
155+
### Features
156+
157+
- add AutoStrategyBuilder, Option<T> KeyProvider, and SecretKey::from_hex
158+
159+
### Fixes
160+
161+
- 🔥 remove unreleased AutoStrategy::new() deprecated method
162+
- 🩹 remove unnecessary bytes.clone() and improve MissingWorkspaceCrn message
163+
- 🩹 address PR review feedback
164+
165+
### Refactoring
166+
167+
- ♻️ replace with_region with with_workspace_crn and add

0 commit comments

Comments
 (0)