I’ve been working on a local-first, open-source Python tool (InBox Wall) to sanitize email HTML before feeding it to a local AI agent via MCP. The goal is to prevent hidden CSS/Unicode prompt injections without sending data to the cloud.
Current approach:
Fetches via read-only IMAP (all processing is local).
Uses css-inline + BeautifulSoup to compute effective styles and strip hidden text.
Quarantines threats in a separate local SQLite DB (dual-database isolation).
Exposes a standard MCP tool for AI agents to safely read sanitized emails.
Known limitations:
It does NOT scan attachments, analyze URLs, or use OCR. It’s strictly a defense-in-depth layer for HTML bodies.
Where I need your help:
I want to make sure this is as robust as possible. For those of you building local MCP workflows or dealing with email parsing:
Are there any HTML/CSS parsing edge cases I’m missing?
Is the dual-database isolation approach overkill, or is it the right move for local security?
What else would you add to make this genuinely useful for your local AI setup?
Read inboxwall/engine/style_utils.py at 781f6c4; didn’t run it, so treat these as things to test:
Three checks look dead. parse_style stores only the value under the property key, but L72, L90 and L100 search for the property name inside that value (height\s*:\s*0 on style_dict.get(“height”), same for text-indent and font-size). So height:0, text-indent:-9999px, and font-size:0% never fire there. font-size:0 and 0px are still caught by the fullmatch at L101-105, but % is not.
max-height:0 with overflow:hidden isn’t checked at all. That is the usual preheader hiding trick.
The clip check wants rect(0,0,0,0) with no spaces, so rect(0 0 0 0) gets through, and clip-path isn’t checked.
White-on-white needs exact literals, so rgb(255, 255, 255) with spaces is missed, and same-colour text on a non-white background is missed. Also, only the style attribute is parsed, so and are ignored unless css_inline converts them. I didn’t check that part.
For 1, matching the value directly (re.fullmatch(r"0(px|%|em)?", value)) should be enough.
I just pushed a fix for all of these. For the dead checks, I updated the logic to match the value directly, which fixed the height, text-indent, and font-size issues. I also added the max-height + overflow: hidden check for the preheader trick.
The clip regex now handles spaces, and I added clip-path too. For the colors, I just strip out the spaces before checking them, so things like rgb(255, 255, 255) get caught now.