Skip to content

Increase default PBKDF2 iterations for session sealing #1313

Description

@FredKSchott

Describe the feature

sealSession() and unsealSession() spread iron-webcrypto's defaults object without overriding the iteration count. The defaults specify iterations: 1 for both encryption and integrity key derivation.

When generateKey() is called with a string password, it performs PBKDF2-SHA1 key derivation using this iteration count. Current OWASP guidance (2023) recommends a minimum of 600,000 PBKDF2-SHA1 iterations for password-derived keys.

The sealed token format exposes the HMAC salt and digest, providing the material needed for offline brute-force of the session password. Benchmarked speeds show ~4,102 attempts/sec with iterations=1 vs ~5.27 attempts/sec with iterations=600000 — a ~677x difference.

Suggested change

Override iron-webcrypto's defaults in sealSession/unsealSession to use at minimum 600,000 PBKDF2 iterations, e.g.:

const sealDefaults = {
  ...ironDefaults,
  encryption: { ...ironDefaults.encryption, iterations: 600_000 },
  integrity: { ...ironDefaults.integrity, iterations: 600_000 },
}

Alternatively, consider switching to a stronger KDF like Argon2 or scrypt.

Workaround

Applications can explicitly configure higher iterations today via useSession() config:

useSession(event, {
  password: 'my-secret',
  seal: {
    encryption: { iterations: 600_000 },
    integrity: { iterations: 600_000 },
  },
})

This option is currently undocumented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions