feat(security): allow named internal hosts with ALLOWED_HOSTS - #21
Merged
Merged
Conversation
0.3.5 refuses every non-public host, so a self-hosted Appwrite that captures its own sites through the internal 'appwrite' service could not upgrade. ALLOWED_HOSTS lists exact hostnames that may resolve privately; every other private, loopback and metadata address stays blocked.
Docker Image Stats
Screenshot benchmark: Average of 3 runs on https://appwrite.io |
🟢 Tier S · Ready to merge
Adds an opt-in ALLOWED_HOSTS list for exact, case-insensitive exceptions to public-host checks. Screenshot and report routes use the new helper, with unit coverage and a configuration example. The README now explicitly documents unchecked redirect hops and recommends outbound network restrictions. Latest changes: The README qualifies its blocking guarantee and documents the redirect-hop limitation with a recommendation to restrict outbound network access.
📂 Walkthrough · 5
✅ Fixed since the last review · 1
Reviewed the commits since |
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.
What does this PR do?
#18 (released in 0.3.5) refuses every host that isn't publicly routable. That's right for Appwrite Cloud, which captures public preview URLs, but it stops self-hosted Appwrite from upgrading: self-hosted captures sites through the internal
appwriteservice (_APP_WORKER_SCREENSHOTS_ROUTER=http://appwrite), and that name resolves to a private Docker-network address.This adds
ALLOWED_HOSTS, a comma-separated list of exact hostnames, matched case-insensitively, that may resolve privately:isAllowedHost(host): allowed if the host is listed, otherwise the existingisPublicHostcheck.assertPublicUrlis renamedassertAllowedUrl, since a listed internal host now passes./v1/screenshotsand/v1/reportsuse it for the first URL and for every request the page makes.appwritedoesn't allow127.0.0.1,169.254.169.254, or any other private name or address.Self-hosted then sets
ALLOWED_HOSTS=appwriteon the browser service and can move to the release that includes this.Out of scope: redirect hops still aren't checked (#20).
Test Plan
bun test tests/unit: 94 pass. New cases cover parsing, a listed host allowed case-insensitively, other private and metadata hosts still blocked with a list set, public hosts unaffected, and nothing private allowed by default.bun run lint(Biome),bun run check(ESLint) andbun run type-checkare clean.localhost:8099:http://localhost:8099/http://127.0.0.1:8099/http://169.254.169.254/https://example.comALLOWED_HOSTSALLOWED_HOSTS=localhostRelated