siyuan-note/siyuan · error

Argon2id Memory too low (minimum 64 MB)

Error message

Argon2id Memory too low (minimum 64 MB)

What it means

Raised by ValidateArgon2Params when p.Memory < 64*1024 (KiB), i.e. below the OWASP-2023 minimum of 64 MB for Argon2id. The guard prevents a weak KDF configuration from weakening notebook encryption; the default is 64 MB.

Source

Thrown at kernel/util/kdf.go:68

// DefaultArgon2Params 返回 OWASP 2023 推荐的 Argon2id 参数。
func DefaultArgon2Params() Argon2Params {
	return Argon2Params{
		Memory:      64 * 1024,
		Iterations:  3,
		Parallelism: 4,
		KeyLength:   32,
	}
}

// ValidateArgon2Params 校验 Argon2id 参数是否在合理范围内,防止恶意备份设置极大内存导致 OOM,
// 或过弱参数降低安全性。
func ValidateArgon2Params(p Argon2Params) (Argon2Params, error) {
	if p.KeyLength != 32 {
		return p, errors.New("Argon2id KeyLength must be 32")
	}
	if p.Memory < 64*1024 {
		return p, errors.New("Argon2id Memory too low (minimum 64 MB)")
	}
	if p.Memory > 256*1024 {
		return p, errors.New("Argon2id Memory too high (maximum 256 MB)")
	}
	if p.Iterations < 3 {
		return p, errors.New("Argon2id Iterations too low (minimum 3)")
	}
	if p.Iterations > 10 {
		return p, errors.New("Argon2id Iterations too high (maximum 10)")
	}
	if p.Parallelism == 0 || p.Parallelism > 16 {
		return p, errors.New("Argon2id Parallelism must be between 1 and 16")
	}
	return p, nil
}

// DeriveKey 用 Argon2id 从密码派生密钥。同一 password+salt+params 多次调用结果一致。
func DeriveKey(password string, salt []byte, p Argon2Params) []byte {

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Set KDFParams.Memory to at least 64*1024 (KiB); DefaultArgon2Params uses 64*1024.
  2. Re-derive the config through the official change-password flow, which always emits valid params.
  3. Remember the unit is KiB, not bytes and not MiB.

Example fix

// before (treated as < 64 MiB)
params := util.Argon2Params{Memory: 64, Iterations: 3, Parallelism: 4, KeyLength: 32}

// after: 64 MiB expressed in KiB
params := util.Argon2Params{Memory: 64 * 1024, Iterations: 3, Parallelism: 4, KeyLength: 32}
Defensive patterns

Strategy: validation

Validate before calling

if p.Memory < 64*1024 {
    p.Memory = 64 * 1024 // clamp to OWASP minimum, expressed in KiB
}
if _, err := util.ValidateArgon2Params(p); err != nil {
    return err
}

Prevention

When it happens

Trigger: KDFParams.Memory is loaded below 65536 (KiB) from a tampered or hand-edited notebook crypto config, or a backup generated by a non-conforming client. Caught during unlock/setup/change-password before DeriveKey runs.

Common situations: Editing conf JSON and shrinking memory to speed up unlock; a legacy or third-party backup with sub-minimum memory; a mis-typed value (e.g. entering MB instead of KiB).

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/c3c9bef94e3dd441. Report an issue: GitHub.