libmagic-type-confusion

Generate deeply nested JSON payloads that bypass libmagic file type validation.

11|1|Updated May 4, 2026
One-click install
npx skills add https://github.com/dreadnode/capabilities --skill libmagic-type-confusion
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: libmagic-type-confusion
Source: https://github.com/dreadnode/capabilities/tree/main/capabilities/web-security/skills/libmagic-type-confusion
Command: npx skills add https://github.com/dreadnode/capabilities --skill libmagic-type-confusion

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Applications that use libmagic or the file command to validate uploaded file types block dangerous formats like HTML, SVG, and executables to prevent attacks. This Skill enables you to bypass these validation checks by exploiting libmagic's JSON nesting depth limit to cause type confusion, allowing you to test if malicious file types can reach downstream processing pipelines.

Core Features & Use Cases

  • libmagic Usage Detection: Identifies if a target application uses libmagic, python-magic, finfo, or related bindings for file type validation.
  • Payload Generation: Creates deeply nested JSON payloads embedded with target file signatures (e.g., PDF, HTML, SVG) that trick libmagic into misidentifying the file type.
  • Use Case: Use this Skill during authorized red teaming engagements to test if your organization's file upload functionality can be exploited to smuggle executable or scriptable content past MIME checks and into trusted processing pipelines.

Quick Start

Use the libmagic-type-confusion skill to generate a deeply nested JSON payload that tricks the target's libmagic-based upload validator into misidentifying a PDF file as JSON, then upload it to the target's file upload endpoint to test if the PDF reaches the downstream processing pipeline.

Frequently Asked Questions about libmagic-type-confusion

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I bypass libmagic file upload validation to smuggle HTML or SVG files?

You can generate deeply nested JSON payloads embedded with target file signatures to trick libmagic, python-magic, or finfo bindings into misclassifying the file type during authorized red teaming engagements.

What is libmagic type confusion and how does it exploit JSON nesting limits?

By embedding target file signatures within deeply nested JSON structures, this technique causes libmagic to hit its parsing depth limit and misclassify the payload, allowing blocked formats to reach downstream processing pipelines.

Can I use this technique to test file upload endpoints that use python-magic or finfo?

Yes, this technique targets applications using libmagic, python-magic, or finfo bindings to validate uploads, allowing you to test if executable or scriptable content can bypass MIME checks and reach trusted processing pipelines.

How do I generate a payload that tricks file command validators into misclassifying a PDF?

Generate a deeply nested JSON payload embedded with the target PDF file signature to trick the libmagic upload validator into misidentifying the file as JSON, then upload it to the endpoint to test downstream processing.

What are the limitations of using deeply nested JSON to bypass MIME type checks?

This technique specifically targets libmagic and file command-based validation; it may fail if the target application uses additional content inspection, different validation libraries, or does not trust the detected file type downstream.