This repository was archived by the owner on May 29, 2026. It is now read-only.
fix: GisProxyService SSRF — allowlist bypass + getCapabilities pre-auth missing (C5)#662
Merged
Merged
Conversation
…t check (C5) - C5: getCapabilities now calls isUrlAllowed() before file_get_contents — previously it bypassed the allowlist entirely, allowing file:// LFI and php:// wrappers - C5: isUrlAllowed rewritten to use exact hostname comparison (not str_contains substring) — prevents https://evil.com/?x=pdok.nl bypass - C5: Add scheme allowlist — only https permitted; file://, php://, data: etc. blocked - C5: Add SSRF CIDR block — resolves hostname to IP and blocks RFC1918 (10/8, 172.16/12, 192.168/16), loopback (127/8), and link-local (169.254/16) - C5: TRUSTED_HOSTNAMES list replaces the substring pdok.nl/kadaster.nl checks - 4 new security tests: getCapabilities blocked, non-https blocked, substring-bypass blocked, php:// stream wrapper blocked
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Fixes the two SSRF vulnerabilities in
GisProxyService(issue C5).C5 —
getCapabilitiesbypasses allowlist entirely:getCapabilitiescalledfile_get_contents($capUrl)without first callingisUrlAllowed. Any URL could be passed — includingfile:///etc/passwdandphp://filter/...— and would be fetched and returned in the response body. The method now callsisUrlAllowedat the top and throws 403 if not allowed.C5 — Substring allowlist bypass:
isUrlAllowedusedstr_contains($url, 'pdok.nl')which is bypassable viahttps://evil.com/?x=pdok.nl. Replaced with:TRUSTED_HOSTNAMESlist of exact PDOK/Kadaster host names (checked by exact$host === $trustedcomparison)parse_url()to extract the hostname for comparison — no string-scanning of the full URLhttpspermitted;file://,php://,data:etc. blocked at entryC5 — SSRF against internal services:
Added
isHostSafeFromSsrf()which resolves the hostname viagethostbyname()and checks the resulting IP against RFC1918 (10/8, 172.16/12, 192.168/16), loopback (127/8), and link-local (169.254/16) CIDR ranges.Test plan
testGetCapabilitiesBlocksDisallowedUrl— 403 on non-allowlisted URLtestNonHttpsSchemeIsBlocked— 403 onfile://URLtestSubstringBypassUrlIsBlocked—https://evil.com/?x=pdok.nlrejected (was allowed before fix)testPhpStreamWrapperIsBlocked—php://filter/...rejectedCloses #638