A logout that lasts 120 milliseconds is still a logout, technically. It returns 200, it puts the token on a blacklist, and for about the time it takes to blink, the token really is rejected. Then it works again.
I found this one because I was checking a different question. Late October 2026, local checkout of internxt/drive-server-wip at commit 7d7a8be2, synthetic users, a disposable PostgreSQL on 55432 and a Valkey on 56379. I was going through the authentication module looking at how sessions end, not how they begin. Session termination is a good place to audit because everyone remembers to check the login path and almost nobody re-reads the logout path after the first implementation.
The entire logout use case is 28 lines:
import { JwtService } from '@nestjs/jwt';
import { CacheManagerService } from '../cache-manager/cache-manager.service';
import { Injectable } from '@nestjs/common';
import { JWT_7DAYS_EXPIRATION } from './constants';
@Injectable()
export class AuthUsecases {
constructor(
private readonly cacheManagerService: CacheManagerService,
private readonly jwtService: JwtService,
) {}
async logout(jwt: string) {
const tokenClaims = this.jwtService.decode(jwt);
if (tokenClaims?.jti) {
const currentTime = Math.floor(Date.now() / 1000);
const ttl = tokenClaims.exp - currentTime;
if (ttl > 0) {
await this.cacheManagerService.blacklistJwt(
tokenClaims.jti,
ttl ?? JWT_7DAYS_EXPIRATION,
);
}
}
}
}
jwtService.decode(jwt) gives back the claims. exp is a Unix timestamp in seconds. Date.now() is milliseconds, so Math.floor(Date.now() / 1000) converts the current time into seconds to make the subtraction work. ttl = tokenClaims.exp - currentTime is therefore a number of seconds. If it is positive, the jti goes onto a blacklist for that long. It reads correctly. It is the kind of code you glance at and move on from, which is exactly why I went to look at the other end of the call.
CacheManagerService.blacklistJwt is 3 lines: it takes a jti and a ttl, prefixes the key with jwt:, and forwards both to the cache manager's set with the TTL passed through unchanged. That set API expects milliseconds. The locked version in this repository documents that. So a token with 2 minutes of life left was blacklisted for 120 milliseconds. The ?? JWT_7DAYS_EXPIRATION fallback in the logout code is dead code: ttl is only used inside if (ttl > 0), so it can never be nullish at the point where the fallback would apply. Someone added a safety net to a value that was already guaranteed to be a number. Nobody added the multiplication.
It is worth being precise about what the blacklist is for, because the design is reasonable. A JWT is self-contained: once signed, the server has no session record to delete. To end a session early you need a revocation list, and the natural key is the jti claim with an expiry equal to the token's remaining lifetime. After exp, the token is invalid on its own, so there is no reason to keep the blacklist entry. That is exactly what this code implements. The only thing wrong with it is a factor of one thousand.
I checked the validation side to make sure the blacklist was the only thing standing between a logged-out token and a live session:
async validate(payload): Promise<[User, JwtAuthInfo]> {
try {
if (!payload.payload?.uuid) {
throw new UnauthorizedException('Old token version detected');
}
const jti = payload.jti;
if (jti) {
const isBlacklisted =
await this.cacheManagerService.isJwtBlacklisted(jti);
if (isBlacklisted) {
throw new UnauthorizedException();
}
}
The strategy decodes the payload, extracts the jti, and calls isJwtBlacklisted. If the key exists, the request is rejected. Otherwise any correctly signed token is accepted. There is no second check, no session table, no server-side record of "this user logged out". The blacklist is the entire mechanism. When its 120 milliseconds expire, the token is indistinguishable from one that was never logged out.
The unit conversion already existed elsewhere in the codebase, which made the miss more interesting:
public static daysAgo(days: number): Date {
return Time.dateWithTimeAdded(-days, 'day');
}
public static readonly convertTimestampToDate = (timestamp: number): Date => {
return dayjs(timestamp * 1000).toDate();
};
/**
* Returns a new Date object set to the end of the day (23:59:59.999)
Time.convertTimestampToDate in src/lib/time.ts multiplies by 1000 by hand; one helper knew about seconds and milliseconds, and the logout path did not use it.
I checked the cache-manager version pinned in the repository before writing this up, because a unit mismatch is only a bug if the receiving API really does interpret the number the way I thought. It does: the third argument to set is a TTL in milliseconds. The library is not ambiguous and the code is not ambiguous; the 2 are simply written in different units, and TypeScript types both of them as number. That is the whole difficulty. There is no type, no name and no test between ttl and cacheManager.set that would make a reviewer stop. Every static check passes. Every unit test that mocks the cache manager passes. The bug lives in the space between 2 correct lines.
That is also why the failure is so quiet. Nothing throws. The cache accepts 120 as a TTL, stores the key, and evicts it 120 milliseconds later. From inside the process, the logout looks successful: the blacklist call happened, the key existed, the response was 200. Only an observer with a watch and the original token can see that the containment lasted less than a second. If the test had asserted only "the key exists after logout", it would have passed on the vulnerable code.
I wrote a PoC that signs a short-lived token and uses it against the real HTTP stack. Logout, immediate reuse, a 350-millisecond wait, reuse again:
it('C08: a logged-out signed token becomes usable after its Redis blacklist TTL expires', async () => {
const user = await createTestUser(app);
const original = jwt.decode(user.token) as any;
const token = Sign({
jti: v4(), sub: user.user.uuid, payload: original.payload,
}, getEnv().secrets.jwt, '120s');
const first = await request(app.getHttpServer())
.get('/auth/logout').set('Authorization', `Bearer ${token}`);
expect(first.status).toBe(200);
const blocked = await request(app.getHttpServer())
.get('/auth/logout').set('Authorization', `Bearer ${token}`);
expect(blocked.status).toBe(401);
await new Promise((resolve) => setTimeout(resolve, 350));
const reused = await request(app.getHttpServer())
The result:
expect(first.status).toBe(200);
expect(blocked.status).toBe(401);
await new Promise((resolve) => setTimeout(resolve, 350));
expect(reused.status).toBe(200);
200, then 401, then 200. The same token, the same signature, accepted again about a third of a second after logout. There is nothing exotic here: no race condition, no timing attack, no clock skew. A number in the wrong unit. The reason it matters is the scenario in which a user reaches for the logout button: a token leaked, a session left open on a machine they do not control, a device lost. Logout is the containment control. A 120-millisecond containment control is not one.
The 350-millisecond wait in the test is not arbitrary. The token I signed had 2 minutes of life left, so the blacklist entry, on the vulnerable code, lived for 120 milliseconds. Waiting 350 gives the entry 3 full chances to expire and leaves no room for a slow clock or a busy event loop to explain the second 200 away. I deliberately used the logout endpoint itself for all 3 requests rather than some cheaper authenticated route, because it exercises the same global auth guard a real reuse would. The test is small, but every line of it is load-bearing.
Everything ran through the same harness as the other 12 findings: loopback-only guards at the top of the PoC's beforeAll, a staged test file removed by a trap on exit, synthetic credentials, SendGrid in sandbox mode, jest in band with --forceExit. The 4-line test-only patch for the repository's mock Bridge provider, the one that adds the missing getLimit(), is documented in the harness post, not with the finding.
The report went out on 28 October with the other 12. The fix landed on 29 October in 6a7801c, and it is a better fix than the bug deserved. It adds a named conversion helper Time.secondsToMs, converts the delta before passing it on, puts the unit in the variable name, and renames the cache parameter so the next reader cannot avoid the question:
@@ -1,7 +1,7 @@
import { JwtService } from '@nestjs/jwt';
import { CacheManagerService } from '../cache-manager/cache-manager.service';
import { Injectable } from '@nestjs/common';
-import { JWT_7DAYS_EXPIRATION } from './constants';
+import { Time } from '../../lib/time';
@Injectable()
export class AuthUsecases {
@@ -47,9 +41,13 @@ export class Time {
}
public static readonly convertTimestampToDate = (timestamp: number): Date => {
- return dayjs(timestamp * 1000).toDate();
+ return dayjs(Time.secondsToMs(timestamp)).toDate();
};
@@ -97,11 +97,11 @@ export class CacheManagerService {
return cachedLimit;
}
- async blacklistJwt(jti: string, ttl: number) {
2 e2e tests came with it. One asserts that the token is rejected immediately after logout. The other connects to Redis directly, reads the pTTL of the blacklist key, and compares it with the token's remaining lifetime within 10 seconds:
describe('Logout', () => {
let redisClient: RedisClientType;
const loginAndGetToken = async (): Promise<string> => {
const registrationData = await generateValidRegistrationData();
const { email, password } = await registerUser(registrationData);
const response = await request(app.getHttpServer())
.post('/auth/login/access')
.send({ email, password })
.expect(HttpStatus.OK);
return response.body.newToken;
That second test is the one that would have caught the original bug: it does not check "was something blacklisted", it checks "for how long". The commit also swapped the local cache image from redis:latest to valkey/valkey:8 and exposed port 6379 so the test could reach it from the host, which is a small, honest detail: the reason this bug survived is that there was no test that could observe a TTL from outside the process. Once there was one, the unit error was obvious.
Then the advisory sat. I had filed GHSA-mv5w-7wrf-r458 privately on 29 October, the day of the fix. On 3 November I emailed security@ with links to every advisory and asked who was coordinating. No answer. On 4 November I asked in the public issue whether they needed help and offered to open pull requests. No answer. On 9 November Internxt published the C07 advisory themselves, rated Low, without telling me, so I knew the publishing machinery worked. C08, fixed the same day as C07, stayed unpublished.
On 19 November I wrote in the issue: "Why does noone answer? Why all that silent? All my findings are all valid." On 20 November the issue was closed and locked to collaborators, and C08 appeared as published, High, with my name added under Credits as Reporter. 22 days after the fix, and the same 22 days after the advisory I had filed privately on that 29 October. Nobody had replied to either of my questions; the answer was the published page.
I should correct something I wrote earlier. In the first draft of the disclosure post I said I was not credited on C08. By the time the advisory went live, a credit had been added, zerox80 as Reporter, though the advisory itself was created by the maintainer rather than published from mine, and the credit shows no acceptance. The C07 advisory, by contrast, was published from my draft with the credit accepted and a comment from me asking for public attribution. 2 bugs fixed on the same day, 2 advisories handled 3 weeks apart, 2 different credit states. None of it was explained to me; I read it off the pages. It is a small thing, but it is exactly the kind of small thing a single email would have settled. On GitHub all 8 advisories in this repository now carry the note "This report was submitted with AI assistance", which is worth knowing when you read the discussion around them; the PoCs and test logs are the evidence, not the prose.
The same 20 November also produced the only substantive sentence I received after 29 October, in the now-locked issue; the timeline post quotes it in full. C08 had been fixed for 3 weeks. C03 was fixed and published that day. C09 and C11 were closed without a published fix or a stated reason. C01 and C02, both rated High, stayed in triage.
I keep coming back to the unit. ttl is a perfectly reasonable name for a variable. ttlMs is a reasonable name that also forces a question every time it is passed to a new API. The rename in 6a7801c is not decoration; it is the actual fix, because the bug was never in the arithmetic, it was in the absence of anything that would make a reviewer ask "seconds or milliseconds?". A good regression test does the same job from the other side: it measures the thing the code promises, instead of the thing the code happens to do.
The engineering here took a day. The publishing took 20-3. Between them was a queue nobody answered, a national CERT I had escalated to in early November, and a locked issue. The disclosure schedule I sent on 20 November stands: 1 December 2026 for the timeline and full details of the fixed issues, 18 January 2027 for the rest. I have no evidence the logout bug was exploited. The advisory is open, the PoC is attached, and if Internxt wants a second pair of eyes on any of the fixes, the offer is still open.
22 days is an awkward length of time to hold a fixed vulnerability. The code is public, the fix is public, the regression test is public; the only thing not public was the fact that the advisory existed. Anyone diffing master on 30 October could have seen the ttlMs rename and understood what it meant. That is the strange geometry of unpublished advisories for open-source repositories: the fix lands in the open, and the publication that would tell users to update is the part that waits. From the researcher's side, the same 22 days are spent in a different kind of quiet, checking the advisory page for a status change that never comes, wondering whether the notification email failed, and watching a repository you reported to receive 40 commits that are not about your report.
References: GHSA-mv5w-7wrf-r458, 6a7801c, PR #1256.
Top comments (0)