任何像样的错误信息都像一种神谕。
Any decent error message is a kind of oracle

原始链接: https://digitalseams.com/blog/any-decent-error-message-is-a-kind-of-oracle

传统的用户体验设计优先考虑清晰、信息丰富的错误消息——详细说明问题并提供解决方案。然而,许多看似“糟糕”的错误,例如模糊的登录失败消息(“用户名或密码不正确”),通常是*有意*的安全措施。 这些消息旨在防止“账户枚举”攻击,黑客通过这种攻击确定有效的用户名,然后使用窃取的密码进行后续的“密码填充”尝试。泄露具体的错误细节可能会暴露漏洞。 类似地,看似无用的“Oopsie!”消息通常出现在意外错误中,以避免向潜在攻击者泄露敏感的应用程序信息。 即使在密码学中,错误消息也可能被利用。像“填充预言机攻击”这样的技术表明,解密过程中详细的错误反馈如何允许攻击者逐步解密加密数据。 因此,错误消息设计经常涉及一个权衡:可用性与安全性,使其不再仅仅是关于帮助,而更多的是充当保护性的“预言机”。

## 改进错误信息:一则黑客新闻讨论总结 一则黑客新闻讨论,源于[digitalseams.com 文章](https://digitalseams.com/),围绕着编写有用错误信息的挑战展开。核心观点是,好的错误信息是宝贵的调试工具。 建议包括生成与服务器日志关联的唯一标识符(如 UUID),以便用户报告问题,以及在消息中包含源代码行号。然而,关于使用追踪 ID 等解决方案的实用性,存在争议,这需要预先存在的追踪基础设施(如 OTEL)。 一个关键的争论点是*应该*向用户透露多少信息。一些人反对透露具体的错误细节(例如,指示哪个登录字段不正确),因为存在安全风险和潜在的滥用可能。另一些人强调用户体验,提倡清晰地解释*发生了什么*以及*如何修复*,优先考虑问题是源于用户错误还是系统故障。许多人同意,为支持团队提供一个唯一的错误代码,并结合详细的服务器端日志记录,是一个很好的折衷方案。最终,讨论强调了安全、可用性和有效调试之间的平衡。
相关文章

原文

Classic UX advice is to give useful, informational, actionable error messages. For example, the Nielsen Norman Group recommends:

Concisely and precisely describe the issue. Generic messages such as An error occurred lack context. Provide descriptions of the exact problems to help users understand what happened.

[...]

Offer constructive advice. Merely stating the problem is also not enough; offer some potential remedies.

Tim Neusesser and Evan Sunwall (Nielsen Norman Group): Error-Message Guidelines

Are people just ignoring tried-and-true UX wisdom, or is something else going on? I argue it’s something else.

Any decent error message is a kind of oracle. Bad error messages are usually not incompetence, but the result of specific tradeoffs in the design space. What’s ahead:

  • Everyone’s least favorite login errors

  • Any decent error message is a kind of oracle

  • How I learned to stop worrying and love the oracle

  • Meaningmaking for our error messages

Everyone’s least favorite login errors

As a user, the worst kind of error message is “Username or password is incorrect,” followed by “If the account exists, we sent you a password reset email.” This goes against classic UX guidance about good error messages. 

So why aren’t these errors better? “Password is incorrect, try again.” or, “No account exists for this email.” Is that so hard?

Actually, these kinds of error messages are designed to avoid an account enumeration attack - a way for an attacker to understand whether a particular email has an account on your site. Is that so sensitive? If you run a mental-health app or similar, it could be! And account enumeration often precedes credential stuffing, where an attacker uses previously-breached passwords to get into other accounts where the person re-used the password.

(Side note: that link above goes to my employer’s site, but my writing here is always my own.)

Many “Oopsie woopsie”-style errors are a fallback message that appears in unexpected errors - since the developer doesn’t expect it to happen, it could be dangerous to reveal application context as part of the error. As someone working in security, I absolutely do not want to reveal information about my defenses to a possible attacker. 

This is our first potential oracle: the login page that knows what really went wrong, but might not tell you the truth.

Any decent error message is a kind of oracle

Let’s talk about encryption itself. We know already that encryption isn’t enough to ensure security, but in cryptography, even error messages can be dangerous. 

If we want to encrypt some data, we might use Cipher-Block Chaining (CBC) encryption, which splits the data into fixed-size blocks and encrypts them. To make sure all blocks are the right size, you’ll extend your data with padding of a known format.

What if you add the padding data wrong? Wouldn’t it be useful if the decryption code gave different errors for “couldn’t decrypt due to wrong key or IV” and “couldn’t decrypt due to wrong padding”? 

If you think so, congrats - you’ve just introduced a padding oracle attack. The decryption code’s error message is the “oracle”: you might not know if your padding is correct, but the wise oracle can tell you. But what happens if an attacker can talk to the oracle too?

An attacker can decrypt a stolen message by changing one byte at a time, and seeing if that results in correct padding. They’ll get one byte, then next byte, and so on until the entire message is decrypted.

联系我们 contact @ memedata.com