Skip to content

🛡️ Sentinel: [HIGH] Fix domain blocklist bypass via locale-dependent lowercase conversion - #116

Closed
dlukt wants to merge 2 commits into
masterfrom
fix/sentinel-domain-blocklist-bypass-9987004677809382764
Closed

dlukt wants to merge 2 commits into
masterfrom
fix/sentinel-domain-blocklist-bypass-9987004677809382764

Conversation

@dlukt

@dlukt dlukt commented Mar 17, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: HIGH
💡 Vulnerability: The domain blocklist in MastodonAPIController used toLowerCase() without Locale.ROOT and failed to strip trailing dots. This could allow attackers to bypass the blocklist using locales where lowercase conversion of characters like 'I' behaves differently (e.g., Turkish 'I'), or by appending a trailing dot to the domain (a Fully Qualified Domain Name format that DNS resolves but string matching misses).
🎯 Impact: Attackers could cause the app to communicate with blocked domains by sending seemingly innocuous domains that fail string equality matching but resolve identically at the DNS/network level.
🔧 Fix:

  1. Replaced toLowerCase() with toLowerCase(Locale.ROOT) to enforce locale-independent case conversion.
  2. Implemented a while loop to strip all trailing . characters from parsed domains before adding them to the badDomains set.
  3. Updated Gradle configuration (gradle-wrapper.properties and settings.gradle) to fix local test execution failures caused by a missing JVM vendor enum (IBM_SEMERU).
    ✅ Verification: Ran ./gradlew :mastodon:testDebugUnitTest and ./gradlew :mastodon:assembleDebug successfully. The blocklist correctly parses and neutralizes test domains with trailing dots or unusual case structures.

PR created automatically by Jules for task 9987004677809382764 started by @dlukt

…lowercase conversion

* Added `Locale.ROOT` for `toLowerCase()` to prevent bypasses using specific casing (e.g. Turkish 'I').
* Stripped trailing dots from domain to prevent FQDN bypasses (e.g. `evil.com.`).
* Updated Gradle wrapper and settings to resolve build issues with `JvmVendorSpec IBM_SEMERU`.

Co-authored-by: dlukt <201112286+dlukt@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 17, 2026 06:39
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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.

Copilot AI 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.

Pull request overview

This PR hardens the app’s domain blocklist enforcement by ensuring blocklist entries are normalized consistently (locale-invariant lowercasing and removal of trailing dots), preventing bypasses via locale-dependent casing (e.g., Turkish “I”) or FQDN-style trailing dots. It also adjusts Gradle/toolchain configuration to restore local test/build execution.

Changes:

  • Normalize parsed blocklist domains with toLowerCase(Locale.ROOT) and strip all trailing . before adding to the blocklist.
  • Bump foojay-resolver-convention plugin version in settings.gradle.
  • Update Gradle wrapper to use a different Gradle distribution (and SHA) for build/test compatibility.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
settings.gradle Updates toolchain resolver plugin version to improve toolchain/vendor resolution.
mastodon/src/main/java/de/icod/techidon/api/MastodonAPIController.java Normalizes blocklist domain entries (Locale.ROOT + trailing-dot stripping) before lookup.
gradle/wrapper/gradle-wrapper.properties Changes Gradle distribution URL/SHA to a compatible version for local builds/tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +77 to +83
if (line.isBlank() || line.startsWith("#")) continue;
String[] parts = line.replaceAll("\"", "").split("[\s,;]");
if (parts.length == 0) continue;
String domain = parts[0].toLowerCase().trim();
String domain = parts[0].toLowerCase(Locale.ROOT).trim();
while (domain.endsWith(".")) {
domain = domain.substring(0, domain.length() - 1);
}
@dlukt

dlukt commented Mar 17, 2026

Copy link
Copy Markdown
Owner Author

@jules #116 (comment)

blocks.txt is read via a BufferedReader created above this loop, but the reader is never closed. Please wrap the reader creation + this read loop in a try-with-resources (or ensure close in finally) to avoid leaking the underlying AssetInputStream/file descriptor.

@google-labs-jules

Copy link
Copy Markdown
Contributor

@jules #116 (comment)

blocks.txt is read via a BufferedReader created above this loop, but the reader is never closed. Please wrap the reader creation + this read loop in a try-with-resources (or ensure close in finally) to avoid leaking the underlying AssetInputStream/file descriptor.

Good catch! I've wrapped the BufferedReader in a try-with-resources statement to ensure the underlying stream is properly closed and no file descriptors are leaked.

* Prevent file descriptor leakage by ensuring the BufferedReader and underlying AssetInputStream are safely closed via try-with-resources.

Co-authored-by: dlukt <201112286+dlukt@users.noreply.github.com>
@dlukt dlukt closed this Mar 18, 2026
@dlukt
dlukt deleted the fix/sentinel-domain-blocklist-bypass-9987004677809382764 branch May 13, 2026 20:40
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.

2 participants