#11812: fix: MSTeams attachment fetch follows redirects before allowlist checks
channel: msteams
stale
Cluster:
MSTeams SSRF Protection Enhancements
## Fix Summary
The MSTeams attachment downloader performs an initial fetch with default redirect behavior before enforcing redirect-target allowlist checks. An attacker-controlled allowed URL can redirect to an internal or otherwise disallowed host, causing server-side request forgery (SSRF).
## Issue Linkage
Fixes #11811
## Security Snapshot
- CVSS v3.1: 8.5 (High)
- CVSS v4.0: 8.4 (High)
## Implementation Details
### Files Changed
- `extensions/msteams/src/attachments.test.ts` (+94/-4)
- `extensions/msteams/src/attachments/download.ts` (+56/-34)
### Technical Analysis
The MSTeams attachment downloader performs an initial fetch with default redirect behavior before enforcing redirect-target allowlist checks. An attacker-controlled allowed URL can redirect to an internal or otherwise disallowed host, causing server-side request forgery (SSRF).
## Validation Evidence
- Command: `pnpm vitest run extensions/msteams/src/attachments.test.ts`
- Status: passed
## Risk and Compatibility
non-breaking; no known regression impact
## AI-Assisted Disclosure
GPT-5.3-Codex
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR hardens the MSTeams attachment downloader against SSRF via redirects by switching requests to `redirect: "manual"`, validating each redirect hop against the host allowlist, and only applying auth headers on redirect hops whose host is in `authAllowHosts`. Tests were updated and extended to cover allowlisted vs non-allowlisted redirect behavior.
The core logic change is isolated to `extensions/msteams/src/attachments/download.ts`, with corresponding unit tests in `extensions/msteams/src/attachments.test.ts`.
<h3>Confidence Score: 4/5</h3>
- This PR is largely safe to merge and closes the redirect-based SSRF gap, with one redirect-limit logic bug to fix first.
- Redirect handling is correctly moved to manual mode and each hop is checked against the allowlist; auth headers are also constrained to auth-allowlisted hosts. However, `fetchWithAllowlistedRedirects` currently allows one more redirect hop than intended due to an off-by-one loop condition, which weakens the redirect cap and should be corrected.
- extensions/msteams/src/attachments/download.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#21440: fix(msteams): enforce allowlist checks on redirect hops (SSRF) (#11...
by Asm3r96 · 2026-02-19
90.4%
#23598: fix(msteams): add SSRF protection to attachment downloads via redir...
by lewiswigmore · 2026-02-22
87.1%
#23629: fix(msteams): sanitize error messages sent to users (CWE-209)
by lewiswigmore · 2026-02-22
79.3%
#23596: fix(msteams): add SSRF validation to file consent upload URL
by lewiswigmore · 2026-02-22
79.2%
#8228: fix(link-understanding): block private IPs and internal hostnames i...
by yubrew · 2026-02-03
77.0%
#10902: fix(msteams): fix inline pasted image downloads
by jlian · 2026-02-07
76.8%
#16990: fix(media): strip auth headers on cross-origin redirect in download...
by AI-Reviewer-QS · 2026-02-15
76.3%
#18716: msteams: fix DM image delivery + user target routing
by ktsushilofficial · 2026-02-17
74.6%
#5278: fix(browser): prevent DNS rebinding in extension relay HTTP endpoints
by webvijayi · 2026-01-31
72.5%
#19525: security: add SSRF validation for external URLs
by Mozzzaic · 2026-02-17
72.3%