## TL;DR
Most real mail bodies travel encoded, and an extractor that runs its patterns over the raw transfer encoding sees only base64 noise. Extraction must happen after full MIME decoding: parse the message structure, decode each text part by its declared encoding and charset, decode quoted-printable as well, and also scan decoded attachment text where policy allows. Keep the raw and decoded forms linked, because the raw form is the evidence and the decoded form is the analysis surface.

```text
the agent's ioc extractor failed on base64-encoded bodies mid-run
```

## Use this when
- The extractor finds indicators in some messages but misses them in encoded ones.
- Manual decoding of a missed message body reveals URLs and addresses plainly.

## Not for this skill when
- Indicators are inside an image or a PDF. Decoding text parts will not reach them; use image or document analysis.
- The body is encrypted content. No decoder available to the agent can read it; route to policy handling.

## Steps
1. Take a missed message and manually decode its body parts, confirming indicators appear. Verify: encoding is proven as the cause.
2. Inspect the pipeline order: confirm whether extraction runs before or after MIME parsing and decoding. Verify: the ordering fault is located.
3. Move extraction after decoding, covering base64 and quoted-printable, with charset handling so non-English bodies decode correctly. Verify: encoded test messages yield their indicators.
4. Guard the decoder against hostile input with size limits and error isolation per part. Verify: a malformed encoded part fails alone, not the message.
5. Re-run the campaign set and compare indicator counts before and after. Verify: the increase matches the manually checked expectation.

## Variant phrasings
### ioc extractor base64 encoded body missed indicators
The encoded body variant.
### agent decode mime parts before url extraction
The MIME decoding variant.

Compatibility: Python email library and similar MIME parsers in agent stacks, RFC 2045 transfer encodings.

## Why it happens
Transfer encoding is invisible to humans because clients decode automatically, so it is easy to forget the agent reads the wire form, not the rendered form. Any analysis written against rendered assumptions breaks on the encoded majority of real mail.

## Edge cases / pitfalls
- Nested encoding happens: an encoded attachment inside an encoded body. Decode recursively with a depth cap.
- Attackers double-encode to defeat single-pass decoders. One recursive pass with limits is the practical answer.
- Charsets garble indicators if mishandled; a mangled domain is a missed IOC, so test with non-English samples.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_dSVKCDGXWxc1Ev3WRVJefQ
