Conversation
Adds a Content-Security-Policy frame-ancestors header to the port 8086 (export-and-sign) nginx server block, configurable via the TURNKEY_FRAME_ANCESTORS environment variable. This prevents unauthorized origins from embedding the iframe and exploiting the shared embedded key stored in localStorage. The Dockerfile CMD is updated to run envsubst at startup, substituting only TURNKEY_FRAME_ANCESTORS so nginx's own $variable references are left untouched.
ethankonk
approved these changes
Apr 28, 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.
Closes ENG-3770 /
https://linear.app/turnkey/issue/ENG-3770/sb-2026-3-frames-based-signing-workflow-vulnerable-to-cross-origin
Background
The export-and-sign iframe stores an embedded key in
localStoragescoped to its origin. BecauselocalStorageisshared across all iframes from the same origin regardless of parent, a malicious site can embed the iframe and supply a
valid encrypted bundle — the iframe has no way to distinguish a legitimate parent from an attacker.
Change
Adds a
Content-Security-Policy: frame-ancestorsHTTP response header to the port 8086 (export-and-sign) nginx serverblock. This is enforced by the browser before the iframe loads, preventing unauthorized origins from embedding it in the
first place.
The header value is configurable via the
TURNKEY_FRAME_ANCESTORSenvironment variable, defaulting to'none'(blocksall embedding) if unset. The Dockerfile CMD is updated to run
envsubstat container startup, substituting onlyTURNKEY_FRAME_ANCESTORSso nginx's own$variablereferences are left untouched.Deployment
Set
TURNKEY_FRAME_ANCESTORSin the container environment to the origin(s) allowed to embed the iframe:Testing
With the env var set
docker build -t frames-test .
docker run -p 8086:8086 -e TURNKEY_FRAME_ANCESTORS="https://app.turnkey.com" frames-test
curl -sI http://localhost:8086/ | grep -i content-security-policy
Should return:
content-security-policy: frame-ancestors https://app.turnkey.com
Then test the default (unset) case:
docker run -p 8086:8086 frames-test
curl -sI http://localhost:8086/ | grep -i content-security-policy
Should return:
content-security-policy: frame-ancestors 'none'