Detecting Hidden Data (Steganalysis)
Finding concealed payloads.
Detecting Hidden Data (Steganalysis) is a free Cyber Security Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cyber Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is Steganalysis?
Steganalysis is the science of detecting hidden data the counterpart to steganography. Its goal is not necessarily to read the payload but first to answer a simpler question: does this file contain hidden data at all?
Steganalysis matters for defenders because hidden data evades signature-based tools. A malicious payload smuggled inside an innocent image will pass an antivirus scan and a data-loss-prevention filter the hiding is the whole point.
Detection ranges from trivial (spotting appended files) to extremely hard (statistical detection of well-keyed, fractional-rate embedding).
Types of Steganalysis Attacks
Steganalysis is classified by what the analyst knows, mirroring cryptanalysis:
- Stego-only only the suspect file is available the hardest and most common case.
- Known-cover the original clean cover is also available; comparing reveals changes instantly.
- Known-message the hidden message is known, used to find the embedding method.
- Chosen-stego the analyst can run the embedding tool to study its signature.
Most real-world detection is stego-only, which is why statistical methods are so important you rarely have the original to compare.
Start Simple: File Structure
Before fancy statistics, check the basics. Many amateur attempts are caught by simple structural inspection:
- File size larger than expected for the visible content.
- Trailing data content after the format's end-of-file marker.
- Embedded files a ZIP or executable carved out of an image.
- Readable strings plaintext that should not be in a media file.
Tools like binwalk, strings, and file catch these in seconds.
file suspect.png # confirms the real format vs the extension
binwalk suspect.png # scans for embedded/appended file signatures
strings -n 10 suspect.png # surfaces readable hidden text
exiftool suspect.png # inspects metadata for stashed dataMetadata and Comment Fields
Image and document formats have metadata fields EXIF tags, comment blocks, XMP that can hold arbitrary text. Hiding data here is crude but common because viewers never display it.
Always inspect metadata:
- EXIF comment, UserComment, and ImageDescription fields.
- JPEG/PNG comment chunks.
- PDF object streams and document properties.
This is the lowest-effort hiding spot and therefore one of the first places an analyst looks.
# Dump all metadata, including comment and description fields
exiftool -a -u -g1 suspect.jpg
# Inspect PNG text chunks specifically
pngcheck -v suspect.pngVisual Attacks: Bit Plane Analysis
A powerful technique for LSB detection is bit-plane analysis. An 8-bit image can be split into 8 layers, one per bit position. The highest bit planes carry the recognizable picture; the lowest bit plane normally looks like random noise.
In a clean image, the LSB plane is influenced by natural sensor noise and texture. When data is embedded with full LSB, that plane often shows structure regular patterns, blocks, or visible outlines of the hidden payload.
Tools like StegSolve and zsteg let you view individual bit planes to spot these anomalies by eye.
# zsteg scans PNG/BMP bit planes for hidden content
zsteg -a suspect.png
# StegSolve (GUI) lets you flip through each bit plane visually;
# a structured LSB plane is a strong indicator of embedding.Statistical Steganalysis
The strongest detection is statistical: hidden data subtly disturbs the natural distribution of pixel or coefficient values. Embedding bits flattens randomness in ways that math can spot.
Key methods:
- Chi-square attack detects that pairs of values (like 200/201) become equally frequent, which is unnatural in real images.
- RS analysis (Regular/Singular) estimates the embedding rate by flipping LSBs and measuring how image smoothness responds.
- Sample pair analysis examines relationships between adjacent samples.
These work even when the payload is encrypted, because they detect the act of embedding, not the message.
The Chi-Square Attack Explained
The chi-square attack exploits a specific weakness of sequential LSB embedding. In a natural image, value 200 and value 201 occur with different frequencies. But LSB embedding flips between them based on random payload bits, which tends to make each pair of values (called a Pair of Values, or PoV) roughly equal in frequency.
The chi-square test measures how close these pairs are to equal frequency. A high probability of equality across many pairs signals embedding. By running the test over increasing portions of the image, an analyst can even estimate how much data was hidden and where it stops.
# The chi-square steganalysis tests whether value pairs
# (2k, 2k+1) have become artificially equal in frequency.
# Natural image: unequal counts -> low embedding probability
# LSB-stego image: equalized counts -> high embedding probabilityMachine Learning Steganalysis
Modern steganalysis increasingly uses machine learning. Instead of one fixed statistic, a classifier learns the difference between clean and stego images from many examples.
- Classic ML extracts rich feature sets (like SPAM or SRM features) capturing pixel relationships, then trains a classifier.
- Deep learning uses convolutional neural networks that learn detection features directly from raw images.
ML excels at catching adaptive steganography that defeats hand-crafted statistics, but it requires representative training data and can be evaded by methods it has never seen the cat-and-mouse continues.
Detecting Steganography Tools
Sometimes the easiest detection is identifying the tool rather than the data. Many steganography programs leave recognizable artifacts:
- Specific byte signatures or markers in the file.
- Characteristic capacity-vs-quality trade-offs.
- Known headers from tools like steghide, OpenStego, or OutGuess.
Specialized detectors such as StegExpose and stegdetect screen images for the fingerprints of popular embedding tools. On endpoints, simply detecting that a steganography tool was installed or executed is itself a strong indicator.
# stegdetect screens JPEGs for known tool signatures (jsteg, outguess, etc.)
stegdetect -t jopi suspect.jpg
# StegExpose batch-scores a directory of images for likely LSB stego
java -jar StegExpose.jar ./images/Active Steganalysis and Sanitization
When you cannot reliably detect hidden data, you can still neutralize it. Active steganalysis destroys payloads without needing to find them:
- Re-encoding recompress every image (e.g. to a fresh JPEG) at the gateway, destroying naive LSB data.
- Resizing/cropping resampling alters every pixel value.
- Metadata stripping remove all EXIF and comment fields.
- Format normalization convert all uploads to a single canonical format.
This is a practical defense for email gateways and content platforms: assume hiding may exist and scrub it preemptively.
# Sanitize an image at a gateway: strip metadata + re-encode
exiftool -all= clean_candidate.jpg
convert input.png -resize 99% -strip output.jpg # ImageMagick re-encodeA Practical Detection Workflow
Put it together into a defender's workflow, cheapest checks first:
- 1. Structure run
file,binwalk,stringsfor appended/embedded data. - 2. Metadata inspect EXIF and comment fields with
exiftool. - 3. Visual bit-plane analysis with zsteg or StegSolve.
- 4. Statistical chi-square / RS analysis and tool detectors.
- 5. ML classifier screening at scale.
- 6. Active defense when detection is uncertain, sanitize by re-encoding.
No single test is conclusive; confidence comes from layering them.
Quick Check
Test your understanding of statistical detection.
Recap: Detecting Hidden Data (Steganalysis)
You learned how analysts find concealed payloads.
- Steganalysis first asks whether hidden data exists, not what it says most cases are stego-only.
- Start with cheap structural and metadata checks: file, binwalk, strings, exiftool.
- Bit-plane analysis (zsteg, StegSolve) reveals structure in the LSB plane that betrays embedding.
- Statistical methods chi-square and RS analysis detect the act of embedding even on encrypted payloads.
- Machine learning catches adaptive steganography that defeats fixed statistics.
- Tool detectors and active steganalysis (re-encoding, metadata stripping) identify or neutralize payloads.
- Layer the techniques cheapest first for reliable detection.
Next, we look at covert channels and how attackers exfiltrate data.
Frequently asked questions
Is the “Detecting Hidden Data (Steganalysis)” lesson free?
Yes — the full text of “Detecting Hidden Data (Steganalysis)” is free to read here on the web, and the Cyber Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cyber Security Academy course, upgrade to CoddyKit PRO.
What will I learn in “Detecting Hidden Data (Steganalysis)”?
Finding concealed payloads. You practise Cyber Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cyber Security Academy?
No prior experience is required. Cyber Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Detecting Hidden Data (Steganalysis)” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cyber Security Academy lesson?
Yes. Every Cyber Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What Steganography Is
- Image and Audio Steganography
- Detecting Hidden Data (Steganalysis)
- Covert Channels and Exfiltration