Skip to content

Commit b654c53

Browse files
sarg3ntclaude
andcommitted
docs(rotation): clarify constant-time precondition on MatchToken
Add a note that subtle.ConstantTimeCompare's length-dependent fast-fail is fine here because every kid in the system is exactly 6 chars long (kidLength = 6 hex chars; the legacy entry uses 'legacy' which is also 6 chars by deliberate convention). Custom kids of a different length would naturally hash-mismatch — which is the intended failure mode. Also serves to force a synchronize event so PR #128's CI re-runs on the fix commit; the prior synchronize from fe3c762 didn't trigger workflows (still unclear why; not blocking the work). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9326566 commit b654c53

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

gearbox-agent/internal/framework/crypto/keyring.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ func (kr *KeyRing) Primary() *KeyRingEntry {
212212
// header), but leaking which ones an agent currently accepts via
213213
// timing makes rotation-history enumeration cheap, which we'd rather
214214
// not.
215+
//
216+
// Note: subtle.ConstantTimeCompare returns 0 (without timing-uniform
217+
// comparison) when the two slices differ in length. The kid compare
218+
// is therefore length-dependent — which is fine because every kid in
219+
// the system is the same length (kidLength = 6 hex chars; the legacy
220+
// kid "legacy" is also 6 chars by deliberate convention). Custom
221+
// kids that don't match that length will hash-mismatch on lookup,
222+
// which is the intended failure mode.
215223
func (kr *KeyRing) MatchToken(token string) (*KeyRingEntry, error) {
216224
if strings.HasPrefix(token, tokenPrefix) {
217225
// Prefixed: gbx_<kid>_<b64secret>

0 commit comments

Comments
 (0)