Skip to content

๐Ÿ›ก๏ธ Sentinel: [CRITICAL] Fix Server-Side Request Forgery (SSRF) in webhooks - #627

Closed
seonghobae wants to merge 2 commits into
developfrom
sentinel-ssrf-webhook-3209121968036812837
Closed

๐Ÿ›ก๏ธ Sentinel: [CRITICAL] Fix Server-Side Request Forgery (SSRF) in webhooks#627
seonghobae wants to merge 2 commits into
developfrom
sentinel-ssrf-webhook-3209121968036812837

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

๐Ÿšจ ์‹ฌ๊ฐ๋„
CRITICAL

๐Ÿ’ก ์ทจ์•ฝ์ 
์›นํ›… ์ƒ์„ฑ API (POST /api/orgs/:id/webhooks)์—์„œ ์ž…๋ ฅ๋œ URL์ด ๋‚ด๋ถ€ ๋„คํŠธ์›Œํฌ(์˜ˆ: 127.0.0.1, localhost, 10.x.x.x ๋“ฑ)๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š”์ง€ ๊ฒ€์ฆํ•˜์ง€ ์•Š์•„ SSRF(Server-Side Request Forgery) ์ทจ์•ฝ์ ์ด ์กด์žฌํ–ˆ์Šต๋‹ˆ๋‹ค.

๐ŸŽฏ ์˜ํ–ฅ
์•…์˜์ ์ธ ์‚ฌ์šฉ์ž๊ฐ€ ๋‚ด๋ถ€ ๋„คํŠธ์›Œํฌ์˜ ์„œ๋น„์Šค(์˜ˆ: ํด๋ผ์šฐ๋“œ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ API, ๋กœ์ปฌ ํ˜ธ์ŠคํŠธ์— ๋ฐ”์ธ๋”ฉ๋œ ๊ด€๋ฆฌ์ž ๋„๊ตฌ ๋“ฑ)์— HTTP ์š”์ฒญ์„ ๋ณด๋‚ด ์ •๋ณด๋ฅผ ํƒˆ์ทจํ•˜๊ฑฐ๋‚˜ ์ธ๊ฐ€๋˜์ง€ ์•Š์€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ”ง ์ˆ˜์ • ์‚ฌํ•ญ

  • isSafeWebhookUrl ํ•จ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ URL์„ ํŒŒ์‹ฑํ•˜๊ณ , URL ๊ฐ์ฒด๊ฐ€ ์ •๊ทœํ™”ํ•œ hostname์„ ๊ฒ€์‚ฌํ•˜์—ฌ ๋กœ์ปฌํ˜ธ์ŠคํŠธ, IPv4 ์‚ฌ์„ค ๋Œ€์—ญ, IPv6 ๋ฃจํ”„๋ฐฑ ์ฃผ์†Œ([::1]) ๋“ฑ ๋‚ด๋ถ€๋ง IP๋ฅผ ๊ฑฐ๋ถ€ํ•˜๋„๋ก ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ์ž…๋ ฅ์ด ์œ ํšจํ•œ HTTP/HTTPS URL์ธ์ง€๋ฟ๋งŒ ์•„๋‹ˆ๋ผ, isSafeWebhookUrl์„ ํ†ต๊ณผํ•˜๋Š”์ง€ ํ•จ๊ป˜ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค.

โœ… ํ™•์ธ ๋ฐฉ๋ฒ•

  • npm run test:api๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ์—ฐ๊ด€๋œ ํ…Œ์ŠคํŠธ๊ฐ€ ํ†ต๊ณผํ•˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. (ํ…Œ์ŠคํŠธ ๋‚ด์˜ ๋กœ์ปฌํ˜ธ์ŠคํŠธ ์›นํ›…์„ example.com์œผ๋กœ ์ˆ˜์ •ํ•˜์—ฌ ๋ฐ˜์˜ํ–ˆ์Šต๋‹ˆ๋‹ค.)
  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰ ํ›„ ์›นํ›… URL๋กœ http://127.0.0.1/์„ ์‹œ๋„ํ•˜์—ฌ 400 Bad Request๊ฐ€ ๋ฐ˜ํ™˜๋˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

PR created automatically by Jules for task 3209121968036812837 started by @seonghobae


Devin Review

@google-labs-jules

Copy link
Copy Markdown

๐Ÿ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a ๐Ÿ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 10 minutes.

View limit details

Limit details: Youโ€™ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

โš™๏ธ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 33ef1737-af81-44c3-b4c3-d4a938634504

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 2c32887 and c91715a.

๐Ÿ“’ Files selected for processing (3)
  • .jules/sentinel.md
  • server/app.mjs
  • tests/api/smoke.mjs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread tests/api/smoke.mjs

// ---- Webhooks ----
r = await req(`/api/orgs/${orgAId}/webhooks`, { method: 'POST', headers: auth, body: body({ url: 'http://127.0.0.1:9/hook', events: ['project.update'] }) });
r = await req(`/api/orgs/${orgAId}/webhooks`, { method: 'POST', headers: auth, body: body({ url: 'http://example.com:9/hook', events: ['project.update'] }) });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ”ด Webhook delivery test breaks on switch to remote host

The webhook URL was changed from http://127.0.0.1:9/hook to http://example.com:9/hook. The local address failed instantly with connection-refused, so both delivery attempts recorded within the 900ms wait; the external host silently drops port 9, so sendWebhook hangs until its 3000ms abort. At 900ms no delivery is recorded, so the dels.length >= 2 and attempt === 2 assertions fail.

Prompt for agents
The webhook delivery test at tests/api/smoke.mjs was changed to use http://example.com:9/hook to satisfy the new isSafeWebhookUrl SSRF check, which now rejects 127.0.0.1. The problem: the downstream assertions (lines 290-296) rely on both delivery attempts failing fast and being recorded within a 900ms wait. Against 127.0.0.1:9 the connection was refused immediately, but example.com:9 is an external host that silently drops the connection, so sendWebhook (server/app.mjs:102) will hang until its 3000ms AbortController timeout on each attempt. With attempt 1 recording at ~3s and attempt 2 at ~6.5s, the 900ms wait elapses before any delivery row exists, so dels.length >= 2 and attempt === 2 fail; the test also now depends on real outbound network/DNS. Consider using a URL that passes isSafeWebhookUrl (public/external-looking) but still yields a fast, deterministic connection failure โ€” e.g. a hostname that resolves but with a port that produces an immediate refusal, or a domain guaranteed not to resolve โ€” or increase the wait to exceed the retry timeouts. Ensure the fix keeps the test deterministic and offline-safe.
Devin Review

Was this helpful? React with ๐Ÿ‘ or ๐Ÿ‘Ž to provide feedback.

Comment thread server/app.mjs
Comment on lines +733 to +755
function isSafeWebhookUrl(urlStr) {
let u;
try {
u = new URL(urlStr);
} catch {
return false;
}
const hn = u.hostname;
if (
hn === 'localhost' ||
hn === '[::1]' ||
/^127\.\d+\.\d+\.\d+$/.test(hn) ||
/^10\.\d+\.\d+\.\d+$/.test(hn) ||
/^192\.168\.\d+\.\d+$/.test(hn) ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+$/.test(hn) ||
/^169\.254\.\d+\.\d+$/.test(hn) ||
/^0\.\d+\.\d+\.\d+$/.test(hn) ||
hn === ''
) {
return false;
}
return true;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐ŸŸจ Webhook SSRF filter bypassable via IP encodings and DNS

isSafeWebhookUrl rejects only dotted-decimal private ranges, localhost, and [::1], matching the raw hostname string rather than the resolved address. Integer/hex IPs (http://2130706433/), non-[::1] IPv6 loopback and IPv4-mapped forms, and any public hostname whose DNS resolves to an internal or 169.254.169.254 metadata address all pass, and sendWebhook then fetches them server-side.

Devin Review

Was this helpful? React with ๐Ÿ‘ or ๐Ÿ‘Ž to provide feedback.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Superseded by #588. That PR is the single SSRF remediation path and covers encoded IPs, IPv4/IPv6 special-use ranges, DNS rebinding, pinned connections, and the deterministic delivery tests identified in this PR.

@seonghobae seonghobae closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant