Repository navigation
Validate domain hosts and store codes before they reach nginx - #162
Merged
Merged
Conversation
`host` and `store_code` were written unquoted into the nginx store map that every project shares, and Validate only checked store_type. A value with a space, semicolon or brace closed the map block and injected directives into the http context. Even a typo took nginx down for every project on the machine. Validate now requires a hostname (optionally with a leading `*.`) and a store code that follows Magento's own rule. `magebox domain add` validates before saving, and RenderStoreMap refuses an unsafe entry as a second line of defence.
peterjaap
approved these changes
Nov 12, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
hostandstore_codefrom.magebox.yamlare written unquoted into000-magebox-store-map.conf, which every project shares:Config.Validate()only checkedstore_type. A value with a space,;or}closes themapblock, so astore_codelikex; } server { ... }injects arbitrary directives into thehttpcontext. More practically, an honest typo (a space or hyphen) makes nginx reject the whole config and takes down every project on the machine.Fix
Config.Validate()now checks:host: a valid hostname (letters, digits, inner hyphens, dot-separated, max 253 chars), optionally starting with*.store_code: Magento's own rule,^[A-Za-z][A-Za-z0-9_]*$. Magento already refuses anything else, so no valid existing store is rejected.magebox domain addvalidates before saving, so a bad value never reaches.magebox.yaml.RenderStoreMaprefuses an unsafe host, code or type as a second line of defence.config-options.mddocuments the allowed characters, andCHANGELOG.mdhas an[Unreleased]entry.Projects that fail validation were already skipped by
collectAllProjectConfigs, so one broken project no longer poisons the shared map for the others.Testing
internal/config/store_test.go) and for the render guard (internal/nginx/storemap_test.go)make lint: 0 issuesmake test: passes