Skip to content

Fix Slack token extraction failing on newer LevelDB fragmentation markers#34

Merged
devxoul merged 1 commit intomainfrom
fix/slack-leveldb-marker-parsing
Mar 5, 2026
Merged

Fix Slack token extraction failing on newer LevelDB fragmentation markers#34
devxoul merged 1 commit intomainfrom
fix/slack-leveldb-marker-parsing

Conversation

@devxoul
Copy link
Owner

@devxoul devxoul commented Mar 5, 2026

Summary

Fix invalid_auth errors caused by corrupted token reconstruction from newer LevelDB .ldb files. The parser hardcoded one fragmentation marker pattern (0x19 0x0d 0xf0) but newer compacted files use different prefixes (e.g. 0x15 0x0b 0xf0). When an unrecognized marker's 4th byte happened to be a valid hex character (e.g. 0x43 = C), it leaked into the reconstructed token, corrupting it silently.

Changes

token-extractor.ts

  • Generalize the fragmentation marker check in extractTokenFromBuffer() to match any 4-byte sequence where the 3rd byte is 0xf0, instead of requiring exact 0x19 0x0d prefix bytes. This handles both known marker variants and future ones.

token-extractor.test.ts

  • Add 3 tests covering old marker ([19 0d f0 5e]), new marker with hex-valid 4th byte ([15 0b f0 43]), and new marker with non-hex 4th byte ([15 0b f0 58]).

Verified

  • bun test — 12 pass, 0 fail.
  • bun typecheck — clean.
  • bun lint — clean, 166 files checked.

Summary by cubic

Fixes invalid_auth errors when parsing Slack tokens from LevelDB by handling newer fragmentation markers. The parser now treats any 4-byte marker with 0xf0 as the third byte as a hyphen, preventing stray bytes from corrupting tokens.

  • Bug Fixes
    • Generalized marker detection in extractTokenFromBuffer to match any 4-byte sequence where byte 3 is 0xf0.
    • Added tests for old marker and new markers (with hex-valid and non-hex 4th bytes).

Written for commit d3be0b0. Summary will update on new commits.

…kers

The LDB parser hardcoded one fragmentation marker pattern (0x19 0x0d 0xf0)
but newer compacted files use different prefixes (e.g. 0x15 0x0b 0xf0).
When the 4th byte happened to be a valid hex char, it leaked into the
reconstructed token, corrupting it and causing auth failures.
@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
agent-messenger Ignored Ignored Mar 5, 2026 0:15am

Request Review

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@devxoul devxoul merged commit 109d3d4 into main Mar 5, 2026
5 checks passed
@devxoul devxoul deleted the fix/slack-leveldb-marker-parsing branch March 5, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant