You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gpt-pilot/extensions
Lewis 26644c4b89
fix(msteams): add SSRF protection to attachment downloads via redirect and DNS validation (#23598)
* fix(msteams): add SSRF protection to attachment downloads via redirect and DNS validation

The attachment download flow in fetchWithAuthFallback() followed
redirects automatically on the initial fetch without any allowlist
or IP validation. This allowed DNS rebinding attacks where an
allowlisted domain (e.g. evil.trafficmanager.net) could redirect
or resolve to a private IP like 169.254.169.254, bypassing the
hostname allowlist entirely (issue #11811).

This commit adds three layers of SSRF protection:

1. safeFetch() in shared.ts: a redirect-safe fetch wrapper that uses
   redirect: "manual" and validates every redirect hop against the
   hostname allowlist AND DNS-resolved IP before following it.

2. isPrivateOrReservedIP() + resolveAndValidateIP() in shared.ts:
   rejects RFC 1918, loopback, link-local, and IPv6 private ranges
   for both initial URLs and redirect targets.

3. graph.ts SharePoint redirect handling now also uses redirect:
   "manual" and validates resolved IPs, not just hostnames.

The initial fetch in fetchWithAuthFallback now goes through safeFetch
instead of a bare fetch(), ensuring redirects are never followed
without validation.

Includes 38 new tests covering IP validation, DNS resolution checks,
redirect following, DNS rebinding attacks, redirect loops, and
protocol downgrade blocking.

* fix: address review feedback on SSRF protection

- Replace hand-rolled isPrivateOrReservedIP with SDK's isPrivateIpAddress
  which handles IPv4-mapped IPv6, expanded notation, NAT64, 6to4, Teredo,
  octal IPv4, and fails closed on parse errors
- Add redirect: "manual" to auth retry redirect fetch in download.ts to
  prevent chained redirect attacks bypassing SSRF checks
- Add redirect: "manual" to SharePoint redirect fetch in graph.ts to
  prevent the same chained redirect bypass
- Update test expectations for SDK's fail-closed behavior on malformed IPs
- Add expanded IPv6 loopback (0:0:0:0:0:0:0:1) test case

* fix: type fetchMock as typeof fetch to fix TS tuple index error

* msteams: harden attachment auth and graph redirect fetch flow

* changelog(msteams): credit redirect-safeFetch hardening contributors

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
9 months ago
..
bluebubbles fix(bluebubbles): tighten chat target handling 9 months ago
copilot-proxy fix(ci): sync plugin versions and harden install smoke 9 months ago
device-pair Security: disable plugin runtime command execution primitive (#20828) 9 months ago
diagnostics-otel fix(ci): sync plugin versions and harden install smoke 9 months ago
discord fix(extensions): preserve mediaLocalRoots in telegram/discord sendMedia 9 months ago
feishu fix(feishu): prefer video file_key for inbound media 9 months ago
google-antigravity-auth fix(ci): sync plugin versions and harden install smoke 9 months ago
google-gemini-cli-auth fix(ci): sync plugin versions and harden install smoke 9 months ago
googlechat refactor(channels): reuse runtime group policy helpers 9 months ago
imessage refactor(channels): reuse runtime group policy helpers 9 months ago
irc refactor(channels): reuse runtime group policy helpers 9 months ago
line refactor(channels): reuse runtime group policy helpers 9 months ago
llm-task fix(ci): sync plugin versions and harden install smoke 9 months ago
lobster fix(ci): sync plugin versions and harden install smoke 9 months ago
matrix refactor(channels): reuse runtime group policy helpers 9 months ago
mattermost refactor(channels): reuse runtime group policy helpers 9 months ago
memory-core fix(ci): sync plugin versions and harden install smoke 9 months ago
memory-lancedb fix(ci): sync plugin versions and harden install smoke 9 months ago
minimax-portal-auth fix(ci): sync plugin versions and harden install smoke 9 months ago
msteams fix(msteams): add SSRF protection to attachment downloads via redirect and DNS validation (#23598) 9 months ago
nextcloud-talk refactor(channels): reuse runtime group policy helpers 9 months ago
nostr fix(ci): sync plugin versions and harden install smoke 9 months ago
open-prose fix(ci): sync plugin versions and harden install smoke 9 months ago
phone-control style: align formatting with oxfmt 0.33 9 months ago
qwen-portal-auth TypeScript: add extensions to tsconfig and fix type errors (#12781) 10 months ago
shared refactor(extensions): dedupe connector helper usage 9 months ago
signal refactor(channels): reuse runtime group policy helpers 9 months ago
slack fix(slack extension): preserve thread IDs for read + outbound delivery (#23836) 9 months ago
synology-chat test: speed up slow media and synology suites 9 months ago
talk-voice Gateway/Plugins: device pairing + phone control plugins (#11755) 10 months ago
telegram fix(extensions): preserve mediaLocalRoots in telegram/discord sendMedia 9 months ago
thread-ownership test(extensions): cast fetch mocks to satisfy tsgo 9 months ago
tlon refactor(plugin-sdk): unify channel dedupe primitives 9 months ago
twitch refactor(security): unify secure id paths and guard weak patterns 9 months ago
voice-call fix(voice-call): harden media stream pre-start websocket handling 9 months ago
whatsapp refactor(channels): reuse runtime group policy helpers 9 months ago
zalo test(zalo): broaden webhook monitor coverage 9 months ago
zalouser refactor(channels): reuse runtime group policy helpers 9 months ago