Skip to content

Commit 1b6146c

Browse files
committed
fix: reject malformed dpop htu with a clearer message
1 parent 29a216c commit 1b6146c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/helpers/validate_dpop.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export default async (ctx, accessToken) => {
8484
{
8585
const expected = new URL(ctx.oidc.urlFor(ctx.oidc.route)).href;
8686
const actual = URL.parse(payload.htu);
87-
if (!actual) return false;
87+
if (!actual) {
88+
throw new InvalidDpopProof('DPoP proof htu mismatch');
89+
}
8890
actual.hash = '';
8991
actual.search = '';
9092

test/dpop/dpop.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,16 @@ describe('features.dPoP', () => {
967967
.expect(400)
968968
.expect({ error: 'invalid_dpop_proof', error_description: 'invalid DPoP key binding' });
969969
});
970+
971+
it('should be 400 for malformed htu', async function () {
972+
await this.agent.post('/token')
973+
.auth('client', 'secret')
974+
.send({ grant_type: 'client_credentials' })
975+
.set('DPoP', await DPoP(this.keypair, 'not a url', 'POST'))
976+
.type('form')
977+
.expect(400)
978+
.expect({ error: 'invalid_dpop_proof', error_description: 'DPoP proof htu mismatch' });
979+
});
970980
});
971981

972982
describe('invalid nonce', () => {

0 commit comments

Comments
 (0)