Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

fix(tokens): Hash tokens in tokens module to resist ND2DB-style timing attack#83

Open
Blckbrry-Pi wants to merge 1 commit into06-07-chore_migrate_from_yaml_to_jsonfrom
05-01-fix_tokens_hash_tokens_in_tokens_module_to_resist_nd2db-style_timing_attack
Open

fix(tokens): Hash tokens in tokens module to resist ND2DB-style timing attack#83
Blckbrry-Pi wants to merge 1 commit into06-07-chore_migrate_from_yaml_to_jsonfrom
05-01-fix_tokens_hash_tokens_in_tokens_module_to_resist_nd2db-style_timing_attack

Conversation

@Blckbrry-Pi
Copy link
Copy Markdown
Contributor

@Blckbrry-Pi Blckbrry-Pi commented May 1, 2024

Resolves OGB-53

Copy link
Copy Markdown
Contributor Author

Blckbrry-Pi commented May 1, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Blckbrry-Pi and the rest of your teammates on Graphite Graphite

@Blckbrry-Pi Blckbrry-Pi marked this pull request as ready for review May 1, 2024 20:33
@linear
Copy link
Copy Markdown

linear bot commented May 1, 2024

Copy link
Copy Markdown

@MasterPtato MasterPtato left a comment

Choose a reason for hiding this comment

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

I'm not too familiar with this kind if attack, is it possible to write a unit test that confirms this attack is no longer valid after this patch?

Copy link
Copy Markdown
Contributor Author

I'm not too familiar with this kind if attack, is it possible to write a unit test that confirms this attack is no longer valid after this patch?

Almost definitely not.
The theoretical timing attack I proposed would probably take about 3 days minimum to attempt, and that would be if the attacker was on the lucky side.

I can almost guarantee that this style of timing attack will be impossible until a method is released to manipulate SHA256 hashes bit by bit.

Comment thread modules/tokens/utils/types.ts Outdated
@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-01-fix_tokens_hash_tokens_in_tokens_module_to_resist_nd2db-style_timing_attack branch from b2cefc7 to 3d5d946 Compare May 16, 2024 12:15
@Blckbrry-Pi Blckbrry-Pi requested a review from NathanFlurry May 16, 2024 12:17
@Blckbrry-Pi Blckbrry-Pi force-pushed the 05-01-fix_tokens_hash_tokens_in_tokens_module_to_resist_nd2db-style_timing_attack branch from 3d5d946 to 29dbcf2 Compare May 22, 2024 00:58
req: Request,
): Promise<Response> {
const hashed = await Promise.all(req.tokens.map(hash));
console.log(hashed);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove

row: prisma.Prisma.TokenGetPayload<any>,
): Token {
return {
...withoutKeys(row, ["tokenHash"]),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is more lines of code and harder to understand than just manually passing in each parameter from the row in to the response.

Comment thread modules/tokens/utils/types.ts
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants