Skip to content

Cap config-sync response size and allowlist edited_by#89

Merged
d4rken merged 2 commits into
devfrom
feat/config-sync-response-hardening
May 17, 2026
Merged

Cap config-sync response size and allowlist edited_by#89
d4rken merged 2 commits into
devfrom
feat/config-sync-response-hardening

Conversation

@d4rken

@d4rken d4rken commented May 17, 2026

Copy link
Copy Markdown
Member

Two small defensive changes on the feeder side, both prompted by a threat-model review of the config-sync response path.

The HTTP helpers in apl-feed/http.sh now pass --max-filesize 131072 (128 KiB) to curl, bounding the response body that lands in the feeder's /tmp. The realistic well-formed responses for the status, config-sync, and diagnostics endpoints are all well below that; the cap exists so a compromised or buggy server cannot push a multi-megabyte body in the 30s --max-time window and exhaust an SD-card-backed feeder's tmpfs.

The config-sync response decoder also drops any field whose edited_by value falls outside the {feeder, website, legacy} set — the same allowlist the server's serializer enforces on inbound requests. Today nothing on the feeder evaluates edited_by beyond writing it to feed.meta.json, but the asymmetry was worth closing: a future render path that trusts the choice should not have to rediscover it.

curl now passes --max-filesize 131072 (128 KiB) for both POST helpers so a misbehaving server cannot fill /tmp on a disk-constrained feeder. The config-sync response decoder additionally drops any field whose edited_by is not in {feeder, website, legacy}, mirroring the server's own ChoiceField allowlist on the inbound side.
@d4rken d4rken added the enhancement New feature or request label May 17, 2026
Codex flagged that the dropped-field warn log emitted the attacker-controlled edited_by value unquoted. jq @TSV already strips tabs/newlines, but a value containing spaces or embedded `=` could forge extra key=value pairs in the structured journal stream. Cap the logged token at 64 chars, escape any literal double-quotes, and wrap it in quotes so a downstream log parser sees one field.
@d4rken d4rken merged commit 6e61e73 into dev May 17, 2026
12 checks passed
@d4rken d4rken deleted the feat/config-sync-response-hardening branch May 17, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant