The API examined the token form, not the signature
We found an API that accepted access tokens with an empty signature. The API also accepted tokens with an incorrect signature. For all these tokens, the API sent private content. Write operations on the media pipeline we
We found an API that accepted access tokens with an empty signature. The API also accepted tokens with an incorrect signature. For all these tokens, the API sent private content. Write operations on the media pipeline were also possible.
The company (Ingka Group) confirmed the repair 12 days after our report. This post tells you what was incorrect. It also tells you how to test your API for this problem.
What we found
The API used access tokens to protect user content. The client sends the token with each request.
We sent tokens that had the correct form. But these tokens did not have a correct signature:
- A token with an empty signature
- An HS256 token with an incorrect signature
The API accepted all these tokens. The API examined the form of the token: three parts, a header and a payload. The API did not examine the signature.
If the API does not verify the signature, any person can make a token. The API then accepts this token as a correct token.
Why this problem is not easy to see
In normal use, there is no indication of the problem. Users send correct tokens, and the API sends them their data.
These are frequent causes:
- The code decodes the token, but it does not verify the token. Many libraries have two functions: decode and verify. Some developers use decode because it is more simple.
- The code reads the algorithm from the token header and accepts it. Then a token with
alg: nonecan get access. A token that changes RS256 to HS256 can also get access. - One service verifies the token, but a different service only reads the claims.
How to prevent the problem
1. Verify the token. Do not only decode it. Use the verify function of your library. Specify the algorithms that you accept.
Node.js with jose:
import { jwtVerify, createRemoteJWKSet } from 'jose';
const jwks = createRemoteJWKSet(new URL('https://auth.example.com/.well-known/jwks.json'));
export async function readToken(token) {
const { payload } = await jwtVerify(token, jwks, {
algorithms: ['RS256'], // Specify the algorithms. Do not read them from the token.
issuer: 'https://auth.example.com/',
audience: 'my-api',
});
return payload; // An incorrect signature, issuer or audience causes an error.
}
Python with PyJWT:
import jwt
def read_token(token: str, public_key: str) -> dict:
return jwt.decode(
token,
public_key,
algorithms=["RS256"], # Specify the algorithms. Do not read them from the token header.
audience="my-api",
issuer="https://auth.example.com/",
)
2. Verify the token in each service that accepts it. A gateway that verifies tokens does not give protection to all services. A person can possibly get access to a service behind the gateway directly.
3. Add a negative test. Make a token with an incorrect signature. Make sure that the API sends the status 401. You need approximately 5 minutes for this test. It prevents the same problem in the future.
import { test } from 'node:test';
import assert from 'node:assert/strict';
const b64 = (o) => Buffer.from(JSON.stringify(o)).toString('base64url');
const forged = [
`${b64({ alg: 'RS256', typ: 'JWT' })}.${b64({ sub: 'someone-else' })}.`, // empty signature
`${b64({ alg: 'none', typ: 'JWT' })}.${b64({ sub: 'someone-else' })}.`, // alg: none
`${b64({ alg: 'HS256', typ: 'JWT' })}.${b64({ sub: 'someone-else' })}.d3Jvbmc`, // incorrect signature
];
for (const token of forged) {
test(`rejects a forged token: ${token.slice(0, 24)}…`, async () => {
const res = await fetch('http://localhost:3000/api/me', { headers: { authorization: `Bearer ${token}` } });
assert.equal(res.status, 401);
});
}
Use this test only on your own API.
Timeline
- 10 September 2026: We sent the report.
- 22 September 2026: The company confirmed the repair. The API now rejects incorrect tokens. Access without a login is not possible.
We gave this problem the severity "medium". Access was only possible on this API. But on this API, there was no protection.
We are HIGHLVL, a software studio in Hamburg. We make and maintain software for companies. We also find security problems in large systems. You can read the full case (in German) on our Security Reports page.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.