SermoDigital/jose panics at init under Go 1.27, breaking any binary that links the CLI
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia da go.mod e dai nove file non di test che usano SermoDigital/jose, in particolare util/configv3/default_user_config.go, actor/v7action/token.go, api/cloudcontroller/wrapper/uaa_authentication.go, cf/api/authentication/authentication.go e command/v7/actor.go. Confronta i simboli richiesti con github.com/go-jose/go-jose/v4 e considera l’interfaccia Actor e i fake di counterfeiter. Il lavoro è completato quando la scelta della dipendenza è definita, gli utilizzi e i fake generati sono aggiornati e l’avvio funziona con Go 1.27.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
github.com/SermoDigital/jose registers a hash function against id 0 from
an init function. Go 1.27 rejects that outright, so the panic fires before
main and every binary linking the package crash-loops on startup.
The library is unmaintained — no upstream push since October 2019 — so this
will not be fixed at the source.
The breakage
crypto/none.go registers the "none" algorithm against hash id 0:
func init() {
crypto.RegisterHash(crypto.Hash(0), h)
}
Through Go 1.26, RegisterHash only rejected ids at or above maxHash:
// go1.26
func RegisterHash(h Hash, f func() hash.Hash) {
if h >= maxHash {
panic("crypto: RegisterHash of unknown hash function")
}
hashes[h] = f
}
Go 1.27 added an explicit zero check:
// go1.27
func RegisterHash(h Hash, f func() hash.Hash) {
if h == 0 || h >= maxHash {
panic("crypto: RegisterHash of unknown hash function")
}
...
}
The resulting failure, before any application code runs:
panic: crypto: RegisterHash of unknown hash function
goroutine 1 [running]:
crypto.RegisterHash(...)
/usr/local/go/src/crypto/crypto.go:158
github.com/SermoDigital/jose/crypto.init.0()
.../SermoDigital/jose@v0.9.2-0.20161205224733-f6df55f235c2/crypto/none.go:11
Why this may be more urgent than it looks
This is not gated on the CLI itself moving to Go 1.27. The go directive
sets a language version, not the toolchain that gets linked, and a
toolchain line only sets a minimum — a newer local toolchain still
satisfies it and is what gets used. So the panic depends purely on the Go
version of whoever is building.
That includes projects importing the CLI as a library. Stratos embeds
actor/v7action and actor/v7pushaction to implement cf push, and as of
Go 1.27 cannot produce a working binary at all. The build succeeds — the
failure only shows up at startup, which makes it easy to ship unknowingly.
Scope of a fix
The dependency is used in 9 non-test files, through 4 symbols:
| Symbol | Uses |
|---|---|
jws.ParseJWT |
8 |
jwt.JWT |
14 |
jws.NewJWT |
2 |
jws.Claims |
2 |
Mostly reading claims out of UAA tokens — util/configv3/default_user_config.go,
actor/v7action/token.go, api/cloudcontroller/wrapper/uaa_authentication.go,
cf/api/authentication/authentication.go.
One wrinkle: jwt.JWT appears in command/v7/actor.go, so it is part of the
Actor interface and the counterfeiter fakes would need regenerating. Not a
pure leaf swap.
github.com/go-jose/go-jose/v4 is actively maintained and covers this usage,
but the CLI has no JWT library in go.mod today apart from this one, so the
choice is yours rather than something a drive-by PR should decide. Happy to
put up the PR once you indicate a preferred library.
For context, #1814 and #1892 show this dependency has been awkward before,
for unrelated reasons.
Workaround in the meantime
Consumers can point a replace at a fork with the registration removed.
Dropping it is safe: "none" is installed into the jws signing-method map
by a map literal rather than RegisterSigningMethod, nothing else calls
Available() on it, and SigningMethodNone.Sign/Verify are no-ops that
never construct the hash. The only behavioural change is that
Unsecured.Hasher().Available() reports false.
- Lingua principale
- Go
- Stelle
- 1.9k
- Fork
- 990
- Merge medio
- 1g 7h
- PR unite (30g)
- 8
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cloudfoundry/cli
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
cloudfoundry/cli#3866 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
cloudfoundry/cli#3863 · 1 commento ·
-
Add zsh shell completion Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
cloudfoundry/cli#3794 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
cloudfoundry/cli#3787 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
cloudfoundry/cli#3738 · 4 commenti · 2 reazioni ·
Tutte le issue di cloudfoundry/cli
Issue simili
-
kind/bug needs-triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
matrixorigin/matrixone#29223 ·
-
needs-acceptance wg/data-plane-networking
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vllm-project/semantic-router#4024 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
alexgorbatchev/dotfiles#107 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100