Skip to content

Commit e784f23

Browse files
unraidclaude
andcommitted
fix: validate and encode target sessionId in peer messages
- Trim and normalize target before use - Validate with validateBridgeId allowlist (same as bridgeApi.ts) - URL-encode compatTarget to prevent path traversal/injection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8645d37 commit e784f23

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/bridge/peerSessions.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from 'axios'
22
import { logForDebugging } from '../utils/debug.js'
33
import { errorMessage } from '../utils/errors.js'
4+
import { validateBridgeId } from './bridgeApi.js'
45
import { getBridgeAccessToken } from './bridgeConfig.js'
56
import { getReplBridgeHandle } from './replBridgeHandle.js'
67
import { toCompatSessionId } from './sessionIdCompat.js'
@@ -26,7 +27,8 @@ export async function postInterClaudeMessage(
2627
return { ok: false, error: 'Bridge not connected' }
2728
}
2829

29-
if (!target) {
30+
const normalizedTarget = target.trim()
31+
if (!normalizedTarget) {
3032
return { ok: false, error: 'No target session specified' }
3133
}
3234

@@ -35,11 +37,13 @@ export async function postInterClaudeMessage(
3537
return { ok: false, error: 'No access token available' }
3638
}
3739

38-
const compatTarget = toCompatSessionId(target)
40+
const compatTarget = toCompatSessionId(normalizedTarget)
41+
// Validate against path traversal — same allowlist as bridgeApi.ts
42+
validateBridgeId(compatTarget, 'target sessionId')
3943
const from = toCompatSessionId(handle.bridgeSessionId)
4044
const baseUrl = handle.sessionIngressUrl
4145

42-
const url = `${baseUrl}/v1/sessions/${compatTarget}/messages`
46+
const url = `${baseUrl}/v1/sessions/${encodeURIComponent(compatTarget)}/messages`
4347

4448
const response = await axios.post(
4549
url,

0 commit comments

Comments
 (0)