
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
oidc-token-hash
Advanced tools
oidc-token-hash validates (and generates) ID Token `_hash` claims such as `at_hash` or `c_hash`
oidc-token-hash validates (and generates) ID Token _hash claims such as at_hash or c_hash
Its [
*_hash] value is the base64url encoding of the left-most half of the hash of the octets of the ASCII representation of thetoken/state/codevalue, where the hash algorithm used is the hash algorithm used in thealgHeader Parameter of the ID Token's JOSE Header. For instance, if thealgisRS256, hash thetoken/state/codevalue with SHA-256, then take the left-most 128 bits and base64url encode them. The*_hashvalue is a case sensitive string.
| JWS algorithm | used hash algorithm | Note |
|---|---|---|
| HS256, RS256, PS256, ES256, ES256K | sha256 | |
| HS384, RS384, PS384, ES384 | sha384 | |
| HS512, RS512, PS512, ES512 | sha512 | |
| EdDSA w/ Ed25519 curve | sha512 | connect/issues#1125 |
| EdDSA w/ Ed448 curve | shake256(m, 114) | connect/issues#1125 |
| Ed25519 | sha512 | connect/issues#1125 |
| Ed448 | shake256(m, 114) | connect/issues#1125 |
| ML-DSA-44, ML-DSA-65, ML-DSA-87 | shake256(m, 64) | connect/issues#1125 |
Validating
const oidcTokenHash = require('oidc-token-hash');
const access_token = 'YmJiZTAwYmYtMzgyOC00NzhkLTkyOTItNjJjNDM3MGYzOWIy9sFhvH8K_x8UIHj1osisS57f5DduL-ar_qw5jl3lthwpMjm283aVMQXDmoqqqydDSqJfbhptzw8rUVwkuQbolw';
oidcTokenHash.validate({ claim: 'at_hash', source: 'access_token' }, 'x7vk7f6BvQj0jQHYFIk4ag', access_token, 'RS256'); // => does not throw
oidcTokenHash.validate({ claim: 'at_hash', source: 'access_token' }, 'EGEAhGYyfuwDaVTifvrWSoD5MSy_5hZPy6I7Vm-7pTQ', access_token, 'EdDSA', 'Ed25519'); // => does not throw
oidcTokenHash.validate({ claim: 'at_hash', source: 'access_token' }, 'EGEAhGYyfuwDaVTifvrWSoD5MSy_5hZPy6I7Vm-7pTQ', access_token, 'Ed25519'); // => does not throw
oidcTokenHash.validate({ claim: 'at_hash', source: 'access_token' }, 'x7vk7f6BvQj0jQHYFIk4ag', 'foobar', 'RS256'); // => throws AssertionError, message: at_hash mismatch, expected w6uP8Tcg6K2QR905Rms8iQ, got: x7vk7f6BvQj0jQHYFIk4ag
Generating
// access_token from first example
oidcTokenHash.generate(access_token, 'RS256'); // => 'x7vk7f6BvQj0jQHYFIk4ag'
oidcTokenHash.generate(access_token, 'HS384'); // => 'ups_76_7CCye_J1WIyGHKVG7AAs2olYm'
oidcTokenHash.generate(access_token, 'ES512'); // => 'EGEAhGYyfuwDaVTifvrWSoD5MSy_5hZPy6I7Vm-7pTQ'
oidcTokenHash.generate(access_token, 'Ed25519'); // => 'EGEAhGYyfuwDaVTifvrWSoD5MSy_5hZPy6I7Vm-7pTQ'
oidcTokenHash.generate(access_token, 'EdDSA', 'Ed25519'); // => 'EGEAhGYyfuwDaVTifvrWSoD5MSy_5hZPy6I7Vm-7pTQ'
oidcTokenHash.generate(access_token, 'Ed448'); // => 'jxsy68_eG9-91VnHsZ2VnCr_WqDMv4nspiSuUPRdNZnv1y5lNV3rPVYYWNiY_TbUB1JRwlgiDTzZ'
oidcTokenHash.generate(access_token, 'EdDSA', 'Ed448'); // => 'jxsy68_eG9-91VnHsZ2VnCr_WqDMv4nspiSuUPRdNZnv1y5lNV3rPVYYWNiY_TbUB1JRwlgiDTzZ'
base64url native encoding in Node.js when availableEd448 and shake256 to use 114 bytes outputsha512 for Ed25519 and shake256 for Ed448, refactored API, removed handling of none JWS algbase64url dependencybase64url comeback#valid() now requires a third
argument with the JOSE header alg value, resulting in strict validationFAQs
oidc-token-hash validates (and generates) ID Token `_hash` claims such as `at_hash` or `c_hash`
The npm package oidc-token-hash receives a total of 2,447,519 weekly downloads. As such, oidc-token-hash popularity was classified as popular.
We found that oidc-token-hash demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.