Skip to content

Commit d319384

Browse files
committed
fix(token-vault): replace substring URL matching with strict equality
Fixes a security vulnerability where evaluateUrlForInterception used .includes() for URL matching, allowing allow-list bypass via query parameter injection (e.g. https://evil.com?https://valid.com). Replaces .includes() with === for exact string comparison. Blob URLs now require explicit wildcard patterns (blob:https://origin/*). Also removes @forgerock/token-vault from changeset ignore list to enable re-release.
1 parent 04ae8bb commit d319384

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

.changeset/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"baseBranch": "master",
1414
"updateInternalDependencies": "patch",
1515
"ignore": [
16-
"@forgerock/token-vault",
1716
"autoscript-apps",
1817
"autoscript-suites",
1918
"mock-api",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@forgerock/token-vault': patch
3+
---
4+
5+
fix(security): replace substring URL matching with strict equality in evaluateUrlForInterception to prevent URL allow-list bypass via query parameter injection

packages/token-vault/src/lib/network/network.utilities.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,27 @@ describe('Test network utility functions', () => {
3535
expect(evaluateUrlForInterception(url, urls)).toBe(false);
3636
});
3737

38-
// Test evaluateUrlForInterception with matching URL containing blob
39-
it('evaluateUrlForInterception should return true for matching URLs with blob', () => {
38+
// Test evaluateUrlForInterception rejects blob URLs without explicit pattern
39+
it('evaluateUrlForInterception should return false for blob URLs without explicit blob pattern', () => {
4040
const urls = ['https://example.com', 'https://example.com/*'];
4141
const url = 'blob:https://example.com/1234';
42+
expect(evaluateUrlForInterception(url, urls)).toBe(false);
43+
});
44+
45+
// Test evaluateUrlForInterception matches blob URLs with explicit wildcard pattern
46+
it('evaluateUrlForInterception should return true for blob URLs with explicit blob wildcard', () => {
47+
const urls = ['https://example.com', 'blob:https://example.com/*'];
48+
const url = 'blob:https://example.com/1234';
4249
expect(evaluateUrlForInterception(url, urls)).toBe(true);
4350
});
4451

52+
// Test evaluateUrlForInterception rejects URLs containing a valid URL as a query parameter
53+
it('evaluateUrlForInterception should return false when valid URL appears as query parameter', () => {
54+
const urls = ['https://valid.com'];
55+
const url = 'https://evil.com?https://valid.com';
56+
expect(evaluateUrlForInterception(url, urls)).toBe(false);
57+
});
58+
4559
// Test extractOrigins
4660
it('extractOrigins should return an array of unique origins from array of URLs', () => {
4761
const expected = [

packages/token-vault/src/lib/network/network.utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function evaluateUrlForInterception(url: string, urls: string[]) {
109109
}
110110
}
111111
// Do full URL matching
112-
if (url.includes(u)) {
112+
if (url === u) {
113113
return true;
114114
}
115115
}

0 commit comments

Comments
 (0)