Skip to content

Commit 9ec1be0

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oracle-epm): reject raw backslashes before link parsing
1 parent 68df997 commit 9ec1be0

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

apps/sim/lib/internal/oracle-epm/client.server.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ describe('Oracle EPM guarded client', () => {
492492
it.each(['offset=-10&include=false', 'offset=0&include=false', 'offset=10&include=true'])(
493493
'accepts canonical typed query %s without rewriting the returned URL',
494494
async (query) => {
495-
const href = `${prefix}?${query}&token=signed%2Bquery%2Fsecret`
495+
const href = `${prefix}?${query}&token=signed%2Bquery%2Fsecret%5Cvalue`
496496
const handle = client.validateReturnedLink(policy, { rel: 'next', href })
497497
expect(JSON.stringify(handle)).toBe('{}')
498498
await client.requestValidatedLink(handle)
@@ -605,12 +605,16 @@ describe('Oracle EPM guarded client', () => {
605605
it.each(
606606
[
607607
'https://evil.example.com/gateway/SyntheticAlpha/rest/v3/files/abc?token=x',
608+
'https://epm.example.com\\injected/gateway/SyntheticAlpha/rest/v3/files/abc?token=x',
609+
'https://epm.example.com:443\\injected/gateway/SyntheticAlpha/rest/v3/files/abc?token=x',
610+
'https://epm.example.com\\..\\injected/gateway/SyntheticAlpha/rest/v3/files/abc?token=x',
608611
'https://user@epm.example.com/gateway/SyntheticAlpha/rest/v3/files/abc?token=x',
609612
'https://epm.example.com/SyntheticAlpha/rest/v3/files/abc?token=x',
610613
'https://epm.example.com/gateway/SyntheticAlpha/rest/v3/files/abc?token=x&token=y',
611614
'https://epm.example.com/gateway/SyntheticAlpha/rest/v3/files/abc?unknown=x',
612615
'https://epm.example.com/gateway/SyntheticAlpha/rest/v3/files/abc?token=x#fragment',
613616
'https://epm.example.com/gateway/SyntheticAlpha/rest/v3/files/abc?token=x#',
617+
'https://epm.example.com/gateway/SyntheticAlpha/rest/v3/files/abc?token=x\\y',
614618
'https://epm.example.com/gateway/SyntheticAlpha/rest/v3/files/ab\nc?token=x',
615619
'https://epm.example.com/gateway/SyntheticAlpha/rest/v3/files/\uD800?token=x',
616620
'https://epm.example.com/gateway/SyntheticAlpha/rest//v3/files/abc?token=x',
@@ -639,7 +643,9 @@ describe('Oracle EPM guarded client', () => {
639643
instanceUrl: 'https://epm.example.com/gateway',
640644
accessToken: Buffer.from('u:p').toString('base64'),
641645
})
642-
expect(() => client.validateReturnedLink(policy, { rel: relation, href })).toThrow()
646+
expect(() => client.validateReturnedLink(policy, { rel: relation, href })).toThrowError(
647+
expect.objectContaining({ name: 'OracleEpmError', category: 'invalid_input' })
648+
)
643649
expect(mockValidateUrl).not.toHaveBeenCalled()
644650
expect(mockSecureFetch).not.toHaveBeenCalled()
645651
})

apps/sim/lib/internal/oracle-epm/client.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ function decodeReturnedPathSegment(
369369
}
370370

371371
function rawReturnedPathSegments(href: string): string[] {
372+
if (href.includes('\\')) throw oracleEpmLocalError('invalid_input')
372373
const match = /^https:\/\/[^/?#]*(\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i.exec(href)
373374
if (!match) throw oracleEpmLocalError('invalid_input')
374375
const rawPath = match[1] ?? ''
375-
if (rawPath.includes('\\')) throw oracleEpmLocalError('invalid_input')
376376
if (!rawPath) return []
377377
const segments = rawPath.slice(1).split('/')
378378
if (segments.some((segment) => !segment)) throw oracleEpmLocalError('invalid_input')

0 commit comments

Comments
 (0)