-
Notifications
You must be signed in to change notification settings - Fork 57
[ANCHOR-1290]: SEP-10 client_domain SSRF: ANCHOR-1236 blocklist omits NAT64 (64:ff9b::/96) and 6to4 (2002::/16), re-reaching internal IPv4 on mainnet #2007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amandagonsalves
wants to merge
6
commits into
develop
Choose a base branch
from
fix/anchor-1290
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+163
−8
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1df4fa9
fix(security): unwrap embedded IPv4 in NAT64/6to4 SSRF guard
amandagonsalves 828f0f1
fix: correct IPv4-compatible IPv6 classification in SSRF guard
amandagonsalves 3e0499a
fix: block RFC 8215 local-use NAT64 prefix in SSRF guard
amandagonsalves fcb1816
Merge branch 'develop' into fix/anchor-1290
amandagonsalves f95c174
Merge branch 'develop' into fix/anchor-1290
amandagonsalves e475704
Merge branch 'develop' into fix/anchor-1290
amandagonsalves File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
core/src/test/kotlin/org/stellar/anchor/util/SsrfBlocklistBypassTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package org.stellar.anchor.util | ||
|
|
||
| import org.junit.jupiter.api.Assertions.assertFalse | ||
| import org.junit.jupiter.api.Assertions.assertTrue | ||
| import org.junit.jupiter.api.Test | ||
| import org.stellar.anchor.api.exception.SepException | ||
|
|
||
| class SsrfBlocklistBypassTest { | ||
| private fun guardBlocks(host: String): Boolean = | ||
| try { | ||
| ClientDomainHelper.validateDomainNotPrivateNetwork(host) | ||
| false | ||
| } catch (e: SepException) { | ||
| e.message?.contains("non-public") == true | ||
| } | ||
|
|
||
| @Test | ||
| fun `CONTROL - standard private and reserved ranges are correctly blocked`() { | ||
| for (h in | ||
| listOf( | ||
| "127.0.0.1", | ||
| "10.0.0.1", | ||
| "172.16.0.1", | ||
| "192.168.1.1", | ||
| "169.254.169.254", | ||
| "100.64.0.1", | ||
| "::1", | ||
| "fc00::1", | ||
| "fd00::1", | ||
| "::ffff:10.0.0.1", | ||
|
amandagonsalves marked this conversation as resolved.
|
||
| "::ffff:169.254.169.254", | ||
| "::10.0.0.1" | ||
| )) { | ||
| assertTrue(guardBlocks(h), "$h must be blocked by the private-network guard") | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun `BYPASS - NAT64 (64_ff9b__96) addresses embedding internal IPv4 are now blocked`() { | ||
| for (h in listOf("64:ff9b::a9fe:a9fe", "64:ff9b::a00:1", "64:ff9b::7f00:1")) { | ||
| assertTrue( | ||
| guardBlocks(h), | ||
| "$h reaches an internal IPv4 through a NAT64 gateway and must be blocked" | ||
| ) | ||
| } | ||
| } | ||
|
amandagonsalves marked this conversation as resolved.
|
||
|
|
||
| @Test | ||
| fun `BYPASS - 6to4 (2002__16) addresses embedding internal IPv4 are now blocked`() { | ||
| for (h in listOf("2002:a00:1::", "2002:7f00:1::")) { | ||
| assertTrue( | ||
| guardBlocks(h), | ||
| "$h reaches an internal IPv4 through a 6to4 relay and must be blocked" | ||
| ) | ||
| } | ||
| } | ||
|
amandagonsalves marked this conversation as resolved.
|
||
|
|
||
| @Test | ||
| fun `additional - NAT64 local-use prefix (64_ff9b_1__48, RFC 8215) is blocked`() { | ||
| assertTrue( | ||
| guardBlocks("64:ff9b:1::a00:1"), | ||
| "64:ff9b:1::/48 is the RFC 8215 local-use NAT64 prefix and must be blocked outright" | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `additional - 0_0_0_0_8 range is blocked`() { | ||
| assertTrue(guardBlocks("0.1.2.3"), "0.1.2.3 is in 0.0.0.0/8 and must be blocked") | ||
| } | ||
|
|
||
| @Test | ||
| fun `additional - ordinary IPv6 addresses outside __96 are not misclassified as IPv4-compatible`() { | ||
| assertFalse( | ||
| guardBlocks("::1:a00:1"), | ||
| "::1:a00:1 is an ordinary global IPv6 address, not an IPv4-compatible literal, even though" + | ||
| " its last 32 bits look like a private IPv4 address; it must not be blocked" | ||
|
amandagonsalves marked this conversation as resolved.
|
||
| ) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.