vole
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software:2222/vole.git
A free and open-source forge that lives in your Git repo.
Harden sign-in input bounds and private response caching
25343521418945b250da2fb29d27cffe34ee2a6e · Keenan Nemetz · 3d ago · parent b492b557
Harden sign-in input bounds and private response caching Bound the account name in LoginBegin before it reaches the per-account rate limiter or the ceremony store, and bound the passkey label and the credential fields copied from an authenticator. Rate-limit keys are capped by hashing a long value, forwarding headers used as addresses are capped, and expired limiter entries are swept as the table grows. Mark downloads and rendered pages private unless the repository is readable anonymously. A private repository's artifact, archive, run artifact, raw file, and HTML pages previously either carried a public cache directive or no directive at all, so a shared cache could serve them to an anonymous reader. Refs #209 (01M6S78Y7EQY596Y9TQRSNRVSE). Refs #210 (01M6S7936QAYM9TMSCXCYP2CF9).
forge/identity/passkey_test.go +43
| @@ -3,6 +3,7 @@ package identity | |||
| 3 | 3 | import ( | |
| 4 | 4 | "crypto/rand" | |
| 5 | 5 | "errors" | |
| 6 | "strings" | ||
| 6 | 7 | "testing" | |
| 7 | 8 | "time" | |
| 8 | 9 | ||
| @@ -306,3 +307,45 @@ func TestCreatePasskeySelfRegistration(t *testing.T) { | |||
| 306 | 307 | t.Fatal("duplicate name was accepted") | |
| 307 | 308 | } | |
| 308 | 309 | } | |
| 310 | |||
| 311 | // TestCredentialMetadataIsBounded: a label and the fields copied from the | ||
| 312 | // authenticator are stored beside the credential, so each is bounded before it | ||
| 313 | // reaches the roster. | ||
| 314 | func TestCredentialMetadataIsBounded(t *testing.T) { | ||
| 315 | t.Parallel() | ||
| 316 | cases := []struct { | ||
| 317 | name string | ||
| 318 | mutate func(*Credential) | ||
| 319 | }{ | ||
| 320 | {"label", func(c *Credential) { c.Label = strings.Repeat("x", MaxCredentialLabel+1) }}, | ||
| 321 | {"transports", func(c *Credential) { | ||
| 322 | c.Transport = make([]string, maxCredentialTransports+1) | ||
| 323 | }}, | ||
| 324 | {"transport length", func(c *Credential) { | ||
| 325 | c.Transport = []string{strings.Repeat("x", maxCredentialTransport+1)} | ||
| 326 | }}, | ||
| 327 | {"attachment", func(c *Credential) { | ||
| 328 | c.Authenticator.Attachment = strings.Repeat("x", maxCredentialAttachment+1) | ||
| 329 | }}, | ||
| 330 | {"attestation", func(c *Credential) { | ||
| 331 | c.AttestationType = strings.Repeat("x", maxCredentialAttestation+1) | ||
| 332 | }}, | ||
| 333 | } | ||
| 334 | for _, tc := range cases { | ||
| 335 | cred := testCredential(t, "laptop") | ||
| 336 | tc.mutate(&cred) | ||
| 337 | if err := validateCredential(cred); err == nil { | ||
| 338 | t.Fatalf("%s: an oversized value was accepted", tc.name) | ||
| 339 | } | ||
| 340 | } | ||
| 341 | } | ||
| 342 | |||
| 343 | func TestCredentialLabelBound(t *testing.T) { | ||
| 344 | t.Parallel() | ||
| 345 | if err := ValidateCredentialLabel(strings.Repeat("x", MaxCredentialLabel)); err != nil { | ||
| 346 | t.Fatalf("a label at the limit was refused: %v", err) | ||
| 347 | } | ||
| 348 | if err := ValidateCredentialLabel(" " + strings.Repeat("x", MaxCredentialLabel+1) + " "); err == nil { | ||
| 349 | t.Fatal("an oversized label was accepted") | ||
| 350 | } | ||
| 351 | } | ||