Skip to content

build: centralize MediaWiki plural rules source URL - #45

Merged
kanasimi merged 1 commit into
kanasimi:masterfrom
anupamme:fix-repo-cejs-cwe-918-ssrf-url-validation
Sep 30, 2026
Merged

kanasimi merged 1 commit into
kanasimi:masterfrom
anupamme:fix-repo-cejs-cwe-918-ssrf-url-validation

Conversation

@anupamme

@anupamme anupamme commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The original title/framing of this PR claimed a CWE-918 (SSRF) fix, but that didn't hold up: the URL fetched in _build/build.nodejs.js is a hardcoded string constant, read exactly once at the fetch() call site, with no path into it from resources_path, environment variables, CLI arguments, or any other input. The regex check I'd added validated that constant against a pattern derived from the same constant — it could never fail, so it didn't demonstrate a real security boundary.

I've reworked the change to keep the one genuinely useful part: extracting the URL into a named gettext_plural_rules_source_URL constant instead of an inline literal in the fetch() call. The redundant validation branch and the CWE-918 comment have been removed.

What changed

  • _build/build.nodejs.js: name the MediaWiki plural-rules source URL as a constant; drop the no-op URL validation.

Note

If the source URL ever becomes configurable (env var, CLI flag, etc.), URL validation should be added at that new input boundary, not here.

@kanasimi

Copy link
Copy Markdown
Owner

Since the URL is validated before the fetch() call, I think hard-coding it will suffice.

The prior CWE-918/SSRF framing didn't hold up on review: the URL is a
hardcoded constant, read exactly once at the fetch() call site, with no
path into it from resources_path, env vars, CLI args, or any other
input. The added regex check validated the constant against a pattern
derived from that same constant, so it could never fail and didn't
demonstrate a real trust boundary.

Keep the one useful part of the original change and drop the rest:
name the URL as gettext_plural_rules_source_URL instead of inlining it,
and remove the redundant validation branch and comment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@anupamme
anupamme force-pushed the fix-repo-cejs-cwe-918-ssrf-url-validation branch from 2de03a3 to 2a024e6 Compare September 30, 2026 01:24
@anupamme anupamme changed the title harden: add URL validation in build.nodejs.js (CWE-918) build: centralize MediaWiki plural rules source URL Sep 30, 2026
@anupamme

Copy link
Copy Markdown
Contributor Author

You're right that the URL is currently hard-coded, so the SSRF validation I added is redundant and doesn't demonstrate a meaningful security boundary.

I've revised the PR to remove the SSRF claim and reworked the change to centralize the MediaWiki source URL in a single named constant, used at the one fetch() call site, avoiding the inline literal and making the intended trusted source explicit.

If there's a future requirement to make the source configurable, URL validation should be added at that configuration/input boundary rather than around this hard-coded value.

@kanasimi
kanasimi merged commit 4236bae into kanasimi:master Sep 30, 2026
4 of 8 checks passed
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