Skip to content

[AI] Add SSRF protection to SimpleFIN bank sync integration - #8012

Merged
MatissJanis merged 8 commits into
masterfrom
claude/simplefin-ssrf-protection-Du3JD
Jun 6, 2026
Merged

MatissJanis merged 8 commits into
masterfrom
claude/simplefin-ssrf-protection-Du3JD

Conversation

@MatissJanis

@MatissJanis MatissJanis commented May 31, 2026 •

Copy link
Copy Markdown
Member

Description

Patch a security problem w/ SimpleFIN

Related issue(s)

https://github.com/actualbudget/actual/security/advisories/GHSA-q5j6-rc55-rvqx

Testing

N/A

Checklist

  • Release notes added (see link above)
  • No obvious regressions in affected areas
  • Self-review has been performed - I understand what each change in the code does and why it is needed

claude and others added 2 commits May 28, 2026 17:51
The SimpleFIN integration made server-side HTTP requests to user-controlled
URLs (the base64-encoded claim token and the resulting access-key base URL)
without any validation, unlike the CORS proxy which blocks private IPs via
ipaddr.js.

Add a shared assertUrlAllowed() helper that rejects non-http(s) URLs and
blocks requests to private, loopback, link-local, unique-local, reserved,
broadcast and unspecified addresses. Hostnames are resolved via DNS so names
pointing at internal addresses are blocked too, not just literal IPs. Apply
it before both outbound requests in getAccessKey() and getAccounts().
The CORS proxy had its own inline ipaddr.js private-IP check that
duplicated the logic in the SimpleFIN SSRF helper. Export isBlockedIp()
from util/ssrf and reuse it in app-cors-proxy, removing the duplicate.

This also widens the CORS proxy's coverage to the reserved and broadcast
ranges and normalizes IPv4-mapped IPv6 addresses, matching the SimpleFIN
helper. The cors-proxy tests now exercise the real ipaddr.js against real
private IPs instead of mocking it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@MatissJanis
MatissJanis requested a review from matt-fidd as a code owner May 31, 2026 20:26
@actual-github-bot actual-github-bot Bot changed the title [AI] Add SSRF protection to SimpleFIN bank sync integration [WIP] [AI] Add SSRF protection to SimpleFIN bank sync integration May 31, 2026
@netlify

netlify Bot commented May 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 1dc6913
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/6a2328124c206400088bea12
😎 Deploy Preview https://deploy-preview-8012.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-storybook ready!

Name Link
🔨 Latest commit 8d97838
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-storybook/deploys/6a1c995bfc18dc0008df666d
😎 Deploy Preview https://deploy-preview-8012--actualbudget-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 278e92c4-563a-4008-8e9b-4b2daf484ada

📥 Commits

Reviewing files that changed from the base of the PR and between 78d431d and f36368d.

📒 Files selected for processing (1)
  • packages/sync-server/src/app-simplefin/app-simplefin.js

📝 Walkthrough

Walkthrough

Adds a centralized SSRF utility (isBlockedIp, assertUrlAllowed), applies it to the CORS proxy and SimpleFIN outbound requests, adds comprehensive Vitest coverage for SSRF scenarios (including DNS-mock tests), and updates release notes.

Changes

SSRF Protection Implementation

Layer / File(s) Summary
Core SSRF utility and IP blocking logic
packages/sync-server/src/util/ssrf.ts
Defines blocked IP range classification and exports isBlockedIp() and assertUrlAllowed() to validate literal IPs, enforce http/https, and resolve DNS to check all resolved addresses.
SSRF utility test suite
packages/sync-server/src/util/ssrf.test.ts
Vitest suite with DNS-mocking validates allow/deny cases: public hosts/IPs allowed; cloud metadata, reserved, loopback, private ranges, DNS-rebind, non-http(s), unresolvable, and invalid URLs rejected; option to allow private network tested.
CORS proxy migration to centralized blocking
packages/sync-server/src/app-cors-proxy.js, packages/sync-server/src/app-cors-proxy.test.js
Replaces inline ipaddr.js checks with isBlockedIp() in isUrlAllowed(); tests remove ipaddr mocks and now exercise the shared SSRF logic.
SimpleFIN endpoint SSRF protection
packages/sync-server/src/app-simplefin/app-simplefin.js
Imports assertUrlAllowed() and calls it (with { allowPrivateNetwork: true }) before performing the access-key HTTPS request and before fetching /accounts, implementing manual redirect handling and credential stripping on origin changes.
Release notes documentation
upcoming-release-notes/8012.md
Adds a Bugfix note documenting SSRF protection for the SimpleFIN bank sync integration.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • matt-fidd
  • joel-jeremy

Poem

🐰 I hopped through code to guard the gate,
Private IPs now meet a stricter fate.
DNS and literals checked with care,
SimpleFIN travels only where it’s fair.
The rabbit nods — the network’s aware.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding SSRF protection to SimpleFIN bank sync integration, which aligns with all modified files and the PR objectives.
Description check ✅ Passed The description is related to the changeset, identifying the security problem being patched (SSRF in SimpleFIN) and referencing the relevant security advisory, which matches the PR's scope and objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/simplefin-ssrf-protection-Du3JD

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 and usage tips.

Requests to private, loopback, link-local, and other internal addresses are now blocked.
@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-storybook ready!

Name Link
🔨 Latest commit 6faa317
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-storybook/deploys/6a1c9973936ff9000861be1e
😎 Deploy Preview https://deploy-preview-8012--actualbudget-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
upcoming-release-notes/8012.md (1)

6-6: ⚡ Quick win

Use a more user-facing phrasing in the release note body.

This is concise already, but replacing “SSRF” with plain language would better match release-note style (non-technical for Bugfix entries).

Suggested wording
-Add SSRF protection to the SimpleFIN bank sync integration.
+Improved security for SimpleFIN bank sync to block unsafe internal network requests.

Based on learnings: “For files in upcoming-release-notes/*.md, keep release notes concise: ideally one sentence and non-technical content unless the category is Maintenance.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@upcoming-release-notes/8012.md` at line 6, Update the release note line that
currently reads "Add SSRF protection to the SimpleFIN bank sync integration." to
a concise, non-technical one-sentence phrasing such as "Added protection against
malicious external requests in the SimpleFIN bank sync integration." — replace
the existing sentence in upcoming-release-notes/8012.md (the line containing
"Add SSRF protection to the SimpleFIN bank sync integration.") with the new
user-facing wording and keep it to a single sentence.
packages/sync-server/src/util/ssrf.ts (1)

36-85: 💤 Low value

Consider documenting the TOCTOU/DNS rebinding limitation.

The implementation resolves DNS at check time, but the downstream fetch/https.request will resolve DNS again independently. A sophisticated attacker controlling DNS could return a safe IP on the first lookup (passing validation) and a blocked IP on the second lookup (reaching the internal service).

This is a known limitation of pre-flight DNS validation. The current implementation still provides strong protection against most SSRF vectors. A more robust mitigation would require returning resolved IPs and forcing the HTTP client to connect to those specific addresses (e.g., via custom Agent or socket connect override), but that's a more invasive change.

For now, consider adding a brief comment noting this limitation for future maintainers.

📝 Suggested documentation
 /**
  * Validate that a URL is safe to make a server-side request to, guarding
  * against SSRF. Only http(s) URLs are permitted, and the hostname is resolved
  * via DNS so that hostnames pointing at private/local/link-local addresses are
  * rejected as well as literal IPs. Throws if the URL is not allowed.
+ *
+ * Note: This is a pre-flight check; the actual HTTP client will resolve DNS
+ * independently, leaving a small TOCTOU window for DNS rebinding attacks.
+ * For higher-assurance scenarios, consider pinning the resolved address in the
+ * HTTP agent.
  */
 export async function assertUrlAllowed(targetUrl: string): Promise<void> {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/sync-server/src/util/ssrf.ts` around lines 36 - 85, The
assertUrlAllowed function performs DNS resolution at check time but does not
prevent a TOCTOU/DNS-rebinding attack because downstream HTTP clients will
re-resolve the hostname; add a concise comment above assertUrlAllowed explaining
this limitation (DNS race/rebinding), noting that a stronger mitigation would
require returning resolved IPs and forcing connections to those addresses (e.g.,
custom Agent or socket override), and reference that any future change should
ensure the HTTP client uses the validated IPs to avoid re-resolution.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/sync-server/src/util/ssrf.ts`:
- Around line 36-85: The assertUrlAllowed function performs DNS resolution at
check time but does not prevent a TOCTOU/DNS-rebinding attack because downstream
HTTP clients will re-resolve the hostname; add a concise comment above
assertUrlAllowed explaining this limitation (DNS race/rebinding), noting that a
stronger mitigation would require returning resolved IPs and forcing connections
to those addresses (e.g., custom Agent or socket override), and reference that
any future change should ensure the HTTP client uses the validated IPs to avoid
re-resolution.

In `@upcoming-release-notes/8012.md`:
- Line 6: Update the release note line that currently reads "Add SSRF protection
to the SimpleFIN bank sync integration." to a concise, non-technical
one-sentence phrasing such as "Added protection against malicious external
requests in the SimpleFIN bank sync integration." — replace the existing
sentence in upcoming-release-notes/8012.md (the line containing "Add SSRF
protection to the SimpleFIN bank sync integration.") with the new user-facing
wording and keep it to a single sentence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2922d55c-4633-4207-9244-a20732d17593

📥 Commits

Reviewing files that changed from the base of the PR and between 000d957 and e3490a9.

📒 Files selected for processing (6)
  • packages/sync-server/src/app-cors-proxy.js
  • packages/sync-server/src/app-cors-proxy.test.js
  • packages/sync-server/src/app-simplefin/app-simplefin.js
  • packages/sync-server/src/util/ssrf.test.ts
  • packages/sync-server/src/util/ssrf.ts
  • upcoming-release-notes/8012.md
💤 Files with no reviewable changes (1)
  • packages/sync-server/src/app-cors-proxy.test.js

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 31, 2026
@MatissJanis MatissJanis changed the title [WIP] [AI] Add SSRF protection to SimpleFIN bank sync integration [AI] Add SSRF protection to SimpleFIN bank sync integration May 31, 2026
Comment thread packages/sync-server/src/util/ssrf.ts Outdated
// IP ranges (as classified by ipaddr.js) that must never be reachable from
// server-side requests to user-controlled URLs. linkLocal covers the cloud
// metadata endpoint (169.254.169.254).
const BLOCKED_IP_RANGES = [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we make this configurable? Speaking at least personally, I run my services on a local IP (over Tailscale), and this change would prevent me from running my own SimpleFIN server. Ideally I could do something like "add x IP to allowed IPs" and it would override the blocklist.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I have made some updates to allow local IP usage. Not a big fan of adding a special env var here as it creates friction for self-hosters. Not something we'd want to intentionally add.

WDYT now?

Full disclosure: I don't use simplefin so didn't test this manually. I think it should be fine, but I'm not 100% confident.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, this should definitely address my concern! Personally I'd slightly prefer an environment variable because I know the exact IP that corresponds to my reverse proxy (vs something else), and I do feel like it should be disabled by default so we have "good" defaults eg for pikapods. That would be a breaking change though, so understand where you're coming from. (FWIW, several other open-source projects I use recently made a change to a similar effect.)

Will give this a test when I'm home tonight!

@MatissJanis

Copy link
Copy Markdown
Member Author

I think this should be fine, but would appreciate someone on SimpleFin testing it out (I'm on Gocardless).

The SSRF protection blocked all private/loopback addresses, which broke
self-hosters running their own SimpleFIN bridge on a LAN or VPN IP with
no way to opt back in.

Split the blocked ranges into two tiers: link-local (cloud metadata),
reserved, broadcast and unspecified stay blocked unconditionally, while
private/loopback/unique-local are blocked by default but can be permitted
per-caller via { allowPrivateNetwork: true }. SimpleFIN opts in, so
self-hosting works out of the box with no env var, while the worst-case
cloud-metadata credential-theft vector remains closed. The CORS proxy
keeps the strict default.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@netlify

netlify Bot commented Jun 1, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-storybook ready!

Name Link
🔨 Latest commit 5afa92a
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-storybook/deploys/6a1d7d44b66ed800089e419a
😎 Deploy Preview https://deploy-preview-8012--actualbudget-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/sync-server/src/app-simplefin/app-simplefin.js (1)

393-399: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix SSRF bypass via automatic redirect following in getAccounts
packages/sync-server/src/app-simplefin/app-simplefin.js calls assertUrlAllowed(url.toString(), { allowPrivateNetwork: true }) once, but then does fetch(url.toString(), { redirect: 'follow' }). A hostile bridge can return a 30x with a Location to a blocked destination; fetch will follow it and bypass the SSRF enforcement.
Disable redirect following or manually follow redirects and run assertUrlAllowed() on every Location hop.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/sync-server/src/app-simplefin/app-simplefin.js` around lines 393 -
399, The fetch call in getAccounts currently uses redirect: 'follow' which
allows 30x responses to redirect to potentially disallowed locations after the
initial assertUrlAllowed(url.toString(), { allowPrivateNetwork: true }) check;
change the fetch logic to either (a) set redirect: 'manual' and, if a 3xx is
returned, extract the Location header and call assertUrlAllowed(newLocation, {
allowPrivateNetwork: true }) before following, repeating for each hop, or (b)
implement manual redirect-following loop that performs assertUrlAllowed() on
each Location hop before issuing the next fetch; update the code paths around
the existing assertUrlAllowed and the fetch(...) call accordingly so no
automatic redirect can bypass the check.
packages/sync-server/src/util/ssrf.ts (1)

72-118: ⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

assertUrlAllowed preflights DNS but doesn’t pin the dialed address (TOCTOU/rebinding SSRF risk)

assertUrlAllowed() only returns Promise<void> and discards the resolved DNS answers; it validates using a single dns.lookup(hostname, { all: true }) and never binds the outbound connection to those IPs.

Current call sites validate and then still dial using the original hostname:

  • packages/sync-server/src/app-simplefin/app-simplefin.js (~321): await assertUrlAllowed(token, ...) → https.request(new URL(token), ...)
  • packages/sync-server/src/app-simplefin/app-simplefin.js (~393): await assertUrlAllowed(url.toString(), ...) → fetch(url.toString(), ...)
    (no agent/dispatcher pinning to the validated IPs in this file)

The ssrf.test.ts “rebind.example.com” coverage blocks when one lookup result set contains a private IP, but it doesn’t eliminate time-separated DNS rebinding between validation and the socket being opened.

Fix by changing assertUrlAllowed (or adding a new helper) to return the allowed resolved address(es) and have the caller perform the request through those resolved IPs (e.g., wrap the outbound request to use the vetted IP while preserving Host/SNI), rather than relying on the original hostname after preflight.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/sync-server/src/util/ssrf.ts` around lines 72 - 118,
assertUrlAllowed currently only validates DNS answers and returns void, leaving
a TOCTOU/rebinding SSRF risk; change it to return the vetted resolved addresses
(e.g., array of IP strings or address objects) instead of discarding them.
Update assertUrlAllowed (or add assertUrlAllowedAndResolve) to perform
dnsLookup(hostname, { all: true }), filter out blocked IPs using isBlockedIp,
throw on any blocked/empty result, and return the remaining resolved addresses
to the caller. Then modify callers (e.g., the app-simplefin call sites that call
assertUrlAllowed before https.request or fetch) to use the returned IP(s) when
opening sockets: pin the socket/agent to a vetted IP (or create a custom
Agent/lookup) and preserve the original Host header and SNI by setting the
request Host header to url.host and using servername in TLS options; ensure any
consumer of dnsLookup/addresses uses the returned addresses rather than
re-resolving the hostname.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/sync-server/src/app-simplefin/app-simplefin.js`:
- Around line 393-399: The fetch call in getAccounts currently uses redirect:
'follow' which allows 30x responses to redirect to potentially disallowed
locations after the initial assertUrlAllowed(url.toString(), {
allowPrivateNetwork: true }) check; change the fetch logic to either (a) set
redirect: 'manual' and, if a 3xx is returned, extract the Location header and
call assertUrlAllowed(newLocation, { allowPrivateNetwork: true }) before
following, repeating for each hop, or (b) implement manual redirect-following
loop that performs assertUrlAllowed() on each Location hop before issuing the
next fetch; update the code paths around the existing assertUrlAllowed and the
fetch(...) call accordingly so no automatic redirect can bypass the check.

In `@packages/sync-server/src/util/ssrf.ts`:
- Around line 72-118: assertUrlAllowed currently only validates DNS answers and
returns void, leaving a TOCTOU/rebinding SSRF risk; change it to return the
vetted resolved addresses (e.g., array of IP strings or address objects) instead
of discarding them. Update assertUrlAllowed (or add assertUrlAllowedAndResolve)
to perform dnsLookup(hostname, { all: true }), filter out blocked IPs using
isBlockedIp, throw on any blocked/empty result, and return the remaining
resolved addresses to the caller. Then modify callers (e.g., the app-simplefin
call sites that call assertUrlAllowed before https.request or fetch) to use the
returned IP(s) when opening sockets: pin the socket/agent to a vetted IP (or
create a custom Agent/lookup) and preserve the original Host header and SNI by
setting the request Host header to url.host and using servername in TLS options;
ensure any consumer of dnsLookup/addresses uses the returned addresses rather
than re-resolving the hostname.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8c4c61db-3ce9-430c-9cb0-e808c4ec1649

📥 Commits

Reviewing files that changed from the base of the PR and between e3490a9 and 78d431d.

📒 Files selected for processing (3)
  • packages/sync-server/src/app-simplefin/app-simplefin.js
  • packages/sync-server/src/util/ssrf.test.ts
  • packages/sync-server/src/util/ssrf.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sync-server/src/util/ssrf.test.ts

getAccounts used fetch with redirect: 'follow', so a 3xx response from the
validated SimpleFIN URL could redirect to a blocked internal address after
only the initial URL had been checked.

Follow redirects manually instead, calling assertUrlAllowed on every hop
before fetching, capping at 5 redirects, and dropping Authorization on
cross-origin hops so the bridge credentials cannot leak to a redirect
target. getAccessKey uses https.request, which does not auto-follow
redirects, so it is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@jfdoming

jfdoming commented Jun 6, 2026

Copy link
Copy Markdown
Member

tested and works fine using my simplefin token

@MatissJanis
MatissJanis added this pull request to the merge queue Jun 6, 2026
Merged via the queue into master with commit f667b5c Jun 6, 2026
31 checks passed
@MatissJanis
MatissJanis deleted the claude/simplefin-ssrf-protection-Du3JD branch June 6, 2026 14:22
mbreslow pushed a commit to mbreslow/actual that referenced this pull request Jun 8, 2026
…dget#8012)

* [AI] Add SSRF protection to SimpleFIN bank sync integration

The SimpleFIN integration made server-side HTTP requests to user-controlled
URLs (the base64-encoded claim token and the resulting access-key base URL)
without any validation, unlike the CORS proxy which blocks private IPs via
ipaddr.js.

Add a shared assertUrlAllowed() helper that rejects non-http(s) URLs and
blocks requests to private, loopback, link-local, unique-local, reserved,
broadcast and unspecified addresses. Hostnames are resolved via DNS so names
pointing at internal addresses are blocked too, not just literal IPs. Apply
it before both outbound requests in getAccessKey() and getAccounts().

* [AI] Unify CORS proxy private-IP check with shared SSRF helper

The CORS proxy had its own inline ipaddr.js private-IP check that
duplicated the logic in the SimpleFIN SSRF helper. Export isBlockedIp()
from util/ssrf and reuse it in app-cors-proxy, removing the duplicate.

This also widens the CORS proxy's coverage to the reserved and broadcast
ranges and normalizes IPv4-mapped IPv6 addresses, matching the SimpleFIN
helper. The cors-proxy tests now exercise the real ipaddr.js against real
private IPs instead of mocking it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* [AI] Rename SimpleFIN SSRF release note to match PR number

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Implement SSRF protection for SimpleFIN bank sync

Requests to private, loopback, link-local, and other internal addresses are now blocked.

* [AI] Allow self-hosted private SimpleFIN servers by default

The SSRF protection blocked all private/loopback addresses, which broke
self-hosters running their own SimpleFIN bridge on a LAN or VPN IP with
no way to opt back in.

Split the blocked ranges into two tiers: link-local (cloud metadata),
reserved, broadcast and unspecified stay blocked unconditionally, while
private/loopback/unique-local are blocked by default but can be permitted
per-caller via { allowPrivateNetwork: true }. SimpleFIN opts in, so
self-hosting works out of the box with no env var, while the worst-case
cloud-metadata credential-theft vector remains closed. The CORS proxy
keeps the strict default.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* [AI] Re-validate SSRF rules on each SimpleFIN redirect hop

getAccounts used fetch with redirect: 'follow', so a 3xx response from the
validated SimpleFIN URL could redirect to a blocked internal address after
only the initial URL had been checked.

Follow redirects manually instead, calling assertUrlAllowed on every hop
before fetching, capping at 5 redirects, and dropping Authorization on
cross-origin hops so the bridge credentials cannot leak to a redirect
target. getAccessKey uses https.request, which does not auto-follow
redirects, so it is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
lelemm pushed a commit to lelemm/actual that referenced this pull request Jun 9, 2026
…dget#8012)

* [AI] Add SSRF protection to SimpleFIN bank sync integration

The SimpleFIN integration made server-side HTTP requests to user-controlled
URLs (the base64-encoded claim token and the resulting access-key base URL)
without any validation, unlike the CORS proxy which blocks private IPs via
ipaddr.js.

Add a shared assertUrlAllowed() helper that rejects non-http(s) URLs and
blocks requests to private, loopback, link-local, unique-local, reserved,
broadcast and unspecified addresses. Hostnames are resolved via DNS so names
pointing at internal addresses are blocked too, not just literal IPs. Apply
it before both outbound requests in getAccessKey() and getAccounts().

* [AI] Unify CORS proxy private-IP check with shared SSRF helper

The CORS proxy had its own inline ipaddr.js private-IP check that
duplicated the logic in the SimpleFIN SSRF helper. Export isBlockedIp()
from util/ssrf and reuse it in app-cors-proxy, removing the duplicate.

This also widens the CORS proxy's coverage to the reserved and broadcast
ranges and normalizes IPv4-mapped IPv6 addresses, matching the SimpleFIN
helper. The cors-proxy tests now exercise the real ipaddr.js against real
private IPs instead of mocking it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* [AI] Rename SimpleFIN SSRF release note to match PR number

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Implement SSRF protection for SimpleFIN bank sync

Requests to private, loopback, link-local, and other internal addresses are now blocked.

* [AI] Allow self-hosted private SimpleFIN servers by default

The SSRF protection blocked all private/loopback addresses, which broke
self-hosters running their own SimpleFIN bridge on a LAN or VPN IP with
no way to opt back in.

Split the blocked ranges into two tiers: link-local (cloud metadata),
reserved, broadcast and unspecified stay blocked unconditionally, while
private/loopback/unique-local are blocked by default but can be permitted
per-caller via { allowPrivateNetwork: true }. SimpleFIN opts in, so
self-hosting works out of the box with no env var, while the worst-case
cloud-metadata credential-theft vector remains closed. The CORS proxy
keeps the strict default.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* [AI] Re-validate SSRF rules on each SimpleFIN redirect hop

getAccounts used fetch with redirect: 'follow', so a 3xx response from the
validated SimpleFIN URL could redirect to a blocked internal address after
only the initial URL had been checked.

Follow redirects manually instead, calling assertUrlAllowed on every hop
before fetching, capping at 5 redirects, and dropping Authorization on
cross-origin hops so the bridge credentials cannot leak to a redirect
target. getAccessKey uses https.request, which does not auto-follow
redirects, so it is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude <[email protected]>