ory/kratos · error · ErrHashParametersOutOfBounds

firescrypt p= not in [1, ]

Error message

firescrypt p=%d not in [1, %d]

What it means

This error means a Firebase scrypt hash declares a p (parallelization) parameter outside the valid range [1, 10]. p=0 is invalid because it would make the hash do no work; large p multiplies CPU cost linearly (Go runs the p iterations serially), enabling CPU-exhaustion attacks via crafted hashes. It wraps ErrHashParametersOutOfBounds from validateFirebaseScryptParams.

Solutions

  1. Check the p field in the hash string and set it within [1, 10] (Firebase uses p=1)
  2. Re-export or regenerate the hash with standard parameters (ln<=17, r=8, p=1)
  3. If the source account genuinely used p>10, plan a forced password reset / rehash-on-login instead of importing

Example fix

// before (p=32, rejected)
$firescrypt$ln=14$r=8$p=32$...
// after (p=1, accepted)
$firescrypt$ln=14$r=8$p=1$...
Defensive patterns

Strategy: validation

Validate before calling

func firebaseScryptPOK(p uint32) bool { return p >= 1 && p <= 10 }
// Or pre-validate the whole hash: hash.ValidateImportedHash(hashed)

Try / catch

if err := hash.ValidateImportedHash(raw); errors.Is(err, hash.ErrHashParametersOutOfBounds) {
    return fmt.Errorf("invalid firescrypt p: %w", err)
}

Prevention

When it happens

Trigger: decodeFirebaseScryptHash parses a $firescrypt hash with p=0 or p>10, reached via ValidateImportedHash on admin import or during a password comparison of a stored hash.

Common situations: Importing hashes generated with unusually high parallelization; forged or malformed hash strings; copying parameter values from plain scrypt configs where p can legitimately be much larger.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of ory/kratos@b86338da04 (2026-09-07). Data as JSON: /api/errors/3b4453e9331485f3. Report an issue: GitHub.

Appendix: source

Thrown at hash/hash_limits.go:87

	maxPbkdf2Iterations uint32 = 10_000_000

	// maxBcryptCost bounds bcrypt cost. The format spec allows 4–31, but
	// cost grows exponentially: cost 12 (Kratos, PHP, Django default) is
	// ~250 ms; cost 14 (high-security guidance) is ~1 s; cost 15 (practical
	// max for interactive use) is ~2 s; cost 17 is ~8 s. No mainstream
	// platform defaults above cost 12.
	maxBcryptCost = 15
)

func validateFirebaseScryptParams(logN, r, p uint32) error {
	if logN > maxScryptLogN {
		return errors.Wrapf(ErrHashParametersOutOfBounds, "firescrypt ln=%d exceeds max %d", logN, maxScryptLogN)
	}
	if r == 0 || r > maxScryptR {
		return errors.Wrapf(ErrHashParametersOutOfBounds, "firescrypt r=%d not in [1, %d]", r, maxScryptR)
	}
	if p == 0 || p > maxScryptP {
		return errors.Wrapf(ErrHashParametersOutOfBounds, "firescrypt p=%d not in [1, %d]", p, maxScryptP)
	}
	return nil
}

func validateScryptParams(n, r, p uint32) error {
	if n == 0 || n > maxScryptN {
		return errors.Wrapf(ErrHashParametersOutOfBounds, "scrypt N=%d not in [1, %d]", n, maxScryptN)
	}
	if r == 0 || r > maxScryptR {
		return errors.Wrapf(ErrHashParametersOutOfBounds, "scrypt r=%d not in [1, %d]", r, maxScryptR)
	}
	if p == 0 || p > maxScryptP {
		return errors.Wrapf(ErrHashParametersOutOfBounds, "scrypt p=%d not in [1, %d]", p, maxScryptP)
	}
	return nil
}

func validateArgon2Params(memoryKiB uint64, iterations uint32, parallelism uint8) error {

View on GitHub (pinned to b86338da04)