binary-data-detection

Detect and reject binary input using magic numbers and byte analysis.

836|66|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill binary-data-detection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: binary-data-detection
Source: https://github.com/kreuzberg-dev/html-to-markdown/tree/main/.ai-rulez/domains/safety-sanitization/skills/binary-data-detection
Command: npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill binary-data-detection

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents the processing of potentially harmful binary data by detecting and rejecting it before it can be parsed, enhancing system security and stability.

Core Features & Use Cases

  • Magic Number Identification: Recognizes common binary file signatures (e.g., gzip, zstd, ZIP, PDF).
  • Heuristic Analysis: Analyzes byte patterns like null byte frequency and control character ratios for unknown binary types.
  • UTF-16 Detection: Differentiates between UTF-16 Little Endian and Big Endian encodings.
  • Use Case: Protect a web service endpoint that accepts text input from being exploited by users uploading executable files or malformed data disguised as text.

Quick Start

Use the binary-data-detection skill to validate the input data for safety.

Frequently Asked Questions about binary-data-detection

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

FAQPage Schema
How do I detect and reject binary input data before parsing text?

To prevent security vulnerabilities from binary inputs, validate data using magic number identification for known signatures like gzip or ZIP, and apply heuristic analysis of null byte and control character ratios to detect disguised executables before parsing.

What is magic number identification for binary file detection?

Magic number identification recognizes common binary file signatures, such as those for gzip, zstd, ZIP, and PDF files, allowing the system to detect and reject known binary formats before attempting to parse them as text.

How does heuristic analysis detect unknown binary types in text inputs?

Heuristic analysis detects unknown binary types by evaluating byte patterns, specifically measuring the frequency of null bytes and the ratio of control characters to identify non-text data that lacks a recognizable magic number.

Can I differentiate UTF-16 encoding from binary data during input validation?

Yes, you can differentiate UTF-16 encoding from binary data by identifying specific byte patterns and Byte Order Marks, allowing the system to correctly distinguish between Little Endian and Big Endian UTF-16 text and actual binary payloads.

How do I protect a web service endpoint from executable files disguised as text?

Protect web service endpoints by implementing input validation that checks for binary file signatures and analyzes control character ratios, securely rejecting any detected binary data before it reaches the text processing or parsing logic.

What are the limitations of using null byte ratios for binary detection?

Analyzing null byte ratios relies on heuristic detection, meaning it identifies probabilities rather than certainties, which may require additional validation logic to correctly process legitimate UTF-16 encoded text without falsely rejecting it as binary data.