fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium
Claude Code and agent skill by fuyu12345/terminalgen-skills
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install fuyu12345/terminalgen-skills/clickjacking-x-frame-options-mediumSKILL.md
The same SKILL.md was published earlier as fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium.
Hardening Flask Clickjacking with X-Frame-Options
When to Use
- Patch an existing Flask app to prevent iframe embedding (
X-Frame-Options: DENYor equivalent). - Deliver a scripted fix (e.g.,
/tmp/fix_clickjacking.py) that editsapp.py. - Ensure protection applies to both normal and error responses.
- Work in noisy environments where:
app.pymay already be corrupted by prior attempts,curlmay be unavailable,- Flask
test_client()may fail due dependency mismatch.
Minimal Reliable Workflow
- Inspect current `app.py` before writing any patch logic.
Detect whether it is a real Flask app or a previously written self-modifying script.
- Create a fixer script that performs structural checks, not string-only checks.
Require Flask app indicators (for example: Flask import + app = Flask(...)) before deciding “already fixed.”
- Inject clickjacking protection with `@app.after_request`.
Add a handler that sets:
response.headers['X-Frame-Options'] = 'DENY'- returns
response
Insert immediately after app initialization for clarity and repeatability.
- Make the fixer idempotent safely.
Skip modification only when both decorator and header logic already exist in valid Flask code. Avoid naive checks like “X-Frame-Options exists anywhere in file.”
- If file is not a valid Flask app, restore baseline app first, then apply protection.
This was necessary in multiple runs because app.py contained a script, not routes.
- Execute fixer script and re-open `app.py` to confirm exact resulting code.
- Run runtime verification using tools available in environment.
Prefer standard-library HTTP checks (urllib) against a running server if curl is missing or test_client() breaks.
Common Pitfalls
- False idempotency success from marker-only checks.
Observed failure mode: fixer exited “already present” because header strings existed inside a broken script, leaving app unusable.
- Assuming `app.py` is baseline Flask code.
In all runs, initial app.py was already replaced by a script and could not export app.
- Relying only on `flask.test_client()` in unstable dependency environments.
Observed werkzeug.__version__ AttributeError blocked this path despite correct app logic.
- Relying only on `curl`.
Observed “curl: command not found”; verification must have fallback.
- Treating harness import errors as task failure root cause.
All three grader runs failed at test collection with missing requests in /tests/test_outputs.py; this is harness-side and not evidence of incorrect clickjacking fix.
Verification Strategy
- Static verification (file-level):
- Confirm
/tmp/fix_clickjacking.pyexists and runs withpython /tmp/fix_clickjacking.py. - Confirm
app.pycontains: @app.after_requestX-Frame-Options- original routes (
/,/api/status,/admin).
- Runtime verification (HTTP-level):
- Start app without reloader in background (
import app; app.app.run(...)). - Query:
//api/status/admin- non-existent path (expect 404)
- Assert
X-Frame-Options: DENYappears on all responses, including 404.
- Environment-resilient verification fallback order:
- First choice:
urllib(stdlib). - Optional:
curlif installed. - Avoid blocking on
test_client()if Werkzeug/Flask mismatch appears.
- Harness sanity check:
- If grader fails before tests run (e.g.,
ModuleNotFoundError: requestsduring collection), classify as test-environment issue and rely on direct runtime verification evidence for task correctness.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinggenerated_skills/clickjacking_x_frame_options_medium/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium)