跳到主要内容
uencoder

Pepper

Pepper 是密码哈希时加入的服务器端秘密值(与 salt 不同,全局共享且保密),增加离线攻击难度。

用途

在 salt 之外增加服务器秘密,使数据库泄露不足以离线破解密码。

机制

H(password || salt || pepper)。pepper 全局共享但保密(存在配置/HSM,不在数据库)。数据库泄露时攻击者无 pepper 无法离线哈希。salt 仍每用户唯一。pepper 泄露则退化为仅 salt 保护。

用例

  • 增强密码哈希安全
  • 数据库泄露后额外保护
  • HSM 存储 pepper
  • 合规要求

示例

  • 输入
    H(pass + salt + pepper)
    输出
    The pepper is required for verification

    Pepper kept secret

常见错误

Storing the pepper in the database (the same one as the hashes)
Keep the pepper in config/HSM, separate from the database

相关词条

相关工具

参考链接