Skip to content

Map every failure at the origin to one status - #74

Merged
beetlebugorg merged 2 commits into
mainfrom
fix/origin-status-mapping
Aug 28, 2026
Merged

Map every failure at the origin to one status#74
beetlebugorg merged 2 commits into
mainfrom
fix/origin-status-mapping

Conversation

@beetlebugorg

@beetlebugorg beetlebugorg commented Aug 28, 2026

Copy link
Copy Markdown
Owner

What

DimsOriginStatusMode decides how a failure at the origin reaches the caller. forward is the default and reports the status the origin returned, which is what the module has always done. map reports 404 for a missing source, 504 for a download timeout, and 502 for every other origin failure.

The mapping covers a failure at the origin and nothing else. A malformed geometry fails after a successful fetch, which leaves 200 on the request, and calling that a bad gateway would blame the origin for the caller's mistake. Both modes report the module's own status there.

DimsStatusVerbose decides whether the status page prints the mod_dims, ImageMagick, and libcurl versions. The default is On, which is today's behavior. The counters and the uptime print either way.

src/url.c reads the source URL out of a request path. Three handlers carried a near identical copy of that code, and each looked for http:/ alone.

Why

The status the origin returned became the status mod_dims returned. Combined with a reachable target that makes the service an oracle: 401 says the target exists and wants credentials, a timeout says the port is filtered, and 200 says it is open. A caller learns what is behind the service by reading status codes.

/dims-status/ returns the version of every component to any caller, and the shipped docker/dims.conf exposes the handler with no access control. The versions name each library a caller would need to pick an exploit.

https:/ does not contain http:/, so a TLS source URL in the request path was never found and the request failed as a bad URL. Only the ?url= and ?eurl= forms reached an https origin.

The two response paths still disagree about which status a failure gets. dims_send_image forwards the origin's status where dims_cleanup reports the module's own. Closing that disagreement changes what /dims3/ and /dims4/ return, so map is what closes it.

Verify

make -C test test

184 cases pass, 182 before. No golden file changes.

The suite gains a server on port 8005 with DimsOriginStatusMode map, DimsStatusVerbose off, a one second download timeout, and the sizer enabled. The origin gains /slow.png, which answers five seconds later than any timeout.

test/unit/test_url.c covers the path reader directly: both schemes, a collapsed slash and an escaped one, a path with no URL, and the truncation the caller performs afterwards.

The sizer is not in the shipped configuration, so port 8005 is the first place the allowlist it gained in #73 runs. TestSizerAppliesTheAllowlist covers it.

Breaking

Nothing. Both directives default to today's behavior, and the path reader only finds a URL that failed to parse before.

An https:/ source in the path now reaches the fetch instead of failing as a bad URL. A deployment that relied on that failure gets a connection attempt instead.

The configuration pages do not exist yet, so neither directive is documented outside the httpd -L help text.

- Add DimsOriginStatusMode, which reports 404, 502, and 504 instead of the origin's own status.
- Add DimsStatusVerbose, which hides the component versions from the status page.
- Read an https source URL out of the request path.
@beetlebugorg
beetlebugorg merged commit d4eb7c0 into main Aug 28, 2026
4 checks passed
@beetlebugorg
beetlebugorg deleted the fix/origin-status-mapping branch August 28, 2026 02:23
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.

1 participant