cd /news/large-language-models/bitmask-based-llm-security-firewall-… · home topics large-language-models article
[ARTICLE · art-44524] src=dev.to ↗ pub= topic=large-language-models verified=true sentiment=↑ positive

Bitmask-Based LLM Security Firewall with reskSecure — Block Jailbreaks at Token Level

ReskSecure introduces a bitmask-based security firewall that blocks prompt injection and jailbreak attempts at the logits level, before token sampling. The tool uses YAML-defined policies to detect forbidden patterns and either blocks or penalizes tokens, preventing disallowed tool calls. It integrates as a logits processor in Hugging Face's generate() function and supports multi-tenant deployments with per-request policy masks.

read1 min views1 publishedJun 30, 2026

Links:

Most prompt injection and jailbreak guards work by scanning output text after the model has already generated it. This is too late — the damage is done, the tool call was made, the sensitive data was exfiltrated.

reskSecure takes a different approach: block at the logits level, before the model ever samples the first forbidden token.

reskSecure uses a bitmask-based policy engine. Each policy entry defines a YAML rule with:

When a matching pattern is detected in the current token window, reskSecure either blocks the token entirely or applies a penalty to its probability. The model can never generate disallowed tool call tokens.

version: "1.0"
rules:
  - name: block-ssn
    patterns: ["SSN", "social security", "###-##-####"]
    severity: hard
    response: "This information cannot be shared for security reasons."

  - name: bias-unsafe-code
    patterns: ["eval(", "exec(", "__import__"]
    severity: bias
    bias_value: -5.0
    response: "This operation is restricted."

Then use it as middleware:

from resksecure import SecurityFirewall

firewall = SecurityFirewall(
    policy_dir="./policies/",
    auto_reload=True
)

output = model.generate(
    input_ids=prompt,
    logits_processor=[firewall]
)
pip install resksecure

Most LLM security products scan the output text after generation. reskSecure operates at the logits tensor level — it modifies the output probability distribution before token sampling. This means:

The bitmask approach extends naturally to multi-tenant deployments: each request gets its own capability mask, and the same firewall process enforces different policies per user context.

If you are deploying LLMs into production, a post-generation filter is not enough. Block at the token level with a hot-reloadable bitmask firewall.

Check the docs on resk.fr and star the repo on GitHub. Feedback and PRs welcome.

pip install resksecure

GitHub: https://github.com/Resk-Security/reskSecure

Web: https://resk.fr

── more in #large-language-models 4 stories · sorted by recency
── more on @resksecure 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/bitmask-based-llm-se…] indexed:0 read:1min 2026-06-30 ·