fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium

Claude Code and agent skill by fuyu12345/terminalgen-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Install

npx vskill@latest install fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium

SKILL.md

The same SKILL.md was published earlier as fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium.

yaml
---
name: hardening-flask-clickjacking-x-frame-options
description: Add global clickjacking protection to Flask by injecting an after_request X-Frame-Options header via a fixer script. Use when a task requires patching an existing Flask app from the terminal while preserving routes and covering error responses.
---

Hardening Flask Clickjacking with X-Frame-Options

When to Use

  • Patch an existing Flask app to prevent iframe embedding (X-Frame-Options: DENY or equivalent).
  • Deliver a scripted fix (e.g., /tmp/fix_clickjacking.py) that edits app.py.
  • Ensure protection applies to both normal and error responses.
  • Work in noisy environments where:
  • app.py may already be corrupted by prior attempts,
  • curl may be unavailable,
  • Flask test_client() may fail due dependency mismatch.

Minimal Reliable Workflow

  1. Inspect current `app.py` before writing any patch logic.

Detect whether it is a real Flask app or a previously written self-modifying script.

  1. 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.”

  1. 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.

  1. 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.”

  1. 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.

  1. Execute fixer script and re-open `app.py` to confirm exact resulting code.
  1. 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

  1. Static verification (file-level):
  • Confirm /tmp/fix_clickjacking.py exists and runs with python /tmp/fix_clickjacking.py.
  • Confirm app.py contains:
  • @app.after_request
  • X-Frame-Options
  • original routes (/, /api/status, /admin).
  1. 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: DENY appears on all responses, including 404.
  1. Environment-resilient verification fallback order:
  • First choice: urllib (stdlib).
  • Optional: curl if installed.
  • Avoid blocking on test_client() if Werkzeug/Flask mismatch appears.
  1. Harness sanity check:
  • If grader fails before tests run (e.g., ModuleNotFoundError: requests during 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium/badge)](https://verified-skill.com/skills/fuyu12345/terminalgen-skills/clickjacking-x-frame-options-medium)

Something wrong with this skill or its page? Tell us.