TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What I don't like about JSON Web Tokens

8 点作者 timmclean大约 10 年前

1 comment

zaroth大约 10 年前
If there are libraries that silently accept an unsigned JWT with alg:none, even when they are provided a secret key to verify, that&#x27;s a serious CVE right there...<p>If a secret or public key is passed to the verify function, the function MUST fail if no signature is actually present in the token. E.g. on node-jwt; [1]<p><pre><code> if (parts[2].trim() === &#x27;&#x27; &amp;&amp; secretOrPublicKey){ return done(new JsonWebTokenError(&#x27;jwt signature is required&#x27;)); } </code></pre> As another example, in the C# library, as long as &#x27;RequireSignedTokens&#x27; is true, it will ensure the signature can&#x27;t be stripped. [2] I&#x27;d say that&#x27;s poor design to allow specifying a key and then ignoring it silently if &#x27;RequireSignedTokens&#x27; is false, even if it is true by default, because the combination of &#x27;RequireSignedTokens&#x27; = false, and a non-null key, is invalid.<p>[1] - <a href="https://github.com/auth0/node-jsonwebtoken/blob/master/index.js#L85" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;auth0&#x2F;node-jsonwebtoken&#x2F;blob&#x2F;master&#x2F;index...</a><p>[2] - <a href="https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/master/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs#L910" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;AzureAD&#x2F;azure-activedirectory-identitymod...</a>
评论 #9111426 未加载