Put local privacy checks before optional Bedrock Guardrails calls
A practical look at evaluating sensitive data, prompt manipulation, authorization, and grounding locally before an optional Amazon Bedrock Guardrails call, with a credential-free synthetic demo and explicit fail-closed boundaries.
The first security control in a generative AI application should not automatically send the original prompt somewhere else.
Sometimes that extra service is exactly what the application needs. Sometimes the prompt contains the sensitive data the control is supposed to catch. A team may also need an offline development path, a predictable failure mode, or a clear explanation of the local decision before it enables another cloud integration.
That boundary shaped Bedrock Guardrail Firewall, an open-source policy enforcement layer that evaluates application traffic before and after an optional Amazon Bedrock Guardrails call.
Start with a local decision
The core runtime is one Python file with a standard-library-only local path. It can inspect user input, candidate output, and trusted retrieval context for:
- sensitive data and credentials
- prompt manipulation and obfuscation
- denied topics and policy-controlled terms
- role, capability, classification, and clearance violations
- unsupported output and missing citations
Optional Microsoft Presidio analysis and Amazon Bedrock Guardrails can be enabled when they fit the deployment.
The order matters. Local privacy detection and policy controls run first. Sensitive content can be irreversibly redacted before an optional cloud call. A local decision to review, escalate, or block prevents live content transmission. If Bedrock returns transformed content, the result is size-checked and evaluated again by the local privacy, policy, authorization, and grounding controls.
The strongest decision wins. A permissive integration cannot override a stricter local finding.

Run the sanitized demo without credentials
The fastest way to inspect the decision model is the repository's sanitized offline demo. It uses synthetic fixtures, creates no AWS client, and does not require AWS credentials.
git clone https://github.com/fusiontechstrategies/Bedrock-Guardrail-Firewall.gitcd Bedrock-Guardrail-Firewallpython examples/run_sanitized_demo.py
The demo covers an ordinary request, email redaction, a synthetic identifier, instruction manipulation, prohibited harm, and an unsupported grounded response. It checks the expected action for every case and exits nonzero if a decision regresses.
The current deterministic baseline is:
- 6 of 6 expected decisions matched
- 4 of 4 high-risk cases contained
- 0 evaluation-time Python socket attempts
- 0 raw high-risk values serialized in the result
The runner denies Python socket creation, connection helpers, and name-resolution APIs during evaluation. Runtime imports happen before that guard, so this is a useful regression check rather than a substitute for host, container, or virtual-machine network isolation.
Make cloud use explicit
The AWS integration has three modes:
Mode | Behavior |
|---|---|
disabled | Creates no AWS client and makes no AWS call. |
preview | Shows a redacted request shape without making an AWS call. |
live | Calls the configured AWS services after explicit authorization. |
Live mode requires both
--aws-mode live and --enable-live-aws . This two-part gate is intended to make an accidental cloud call harder.Preview mode is useful during design review because it exposes only lengths, digests, qualifiers, and redaction markers. It does not include the original text.
python orchestrator.py --presidio-mode disabled --aws-mode preview aws-request-preview \ --input "Contact analyst@example.invalid for the approved report."
When live mode is appropriate, the adapter uses the Amazon Bedrock
ApplyGuardrail API for input and output evaluation. It does not invoke a foundation model. Locally sanitized content may still be transmitted to the configured guardrail, so the workload's data-handling requirements still need review.Fail closed when an integration is required
Not every deployment needs the same controls. The balanced profile keeps Presidio and AWS optional. The production profile requires both Presidio and live Bedrock Guardrails and blocks when either control is disabled or unavailable.
That distinction prevents an optional development convenience from quietly becoming a production bypass. Profile selection comes from trusted deployment configuration, not request content.
The runtime returns one of five recommendations:
allow , sanitize , queue_for_review , escalate , or block . Sanitized content is released only for allow and sanitize . Review, escalation, and block decisions return empty content fields with content_released: false .Keep evidence without keeping the prompt
Audit, review, incident, behavior, and metrics records keep metadata rather than raw prompts and responses. Local audit events form a SHA-256 hash chain. Environments that require remote evidence can add KMS signatures, S3 Object Lock storage, and SQS review routing.
These controls do not turn the project into a complete security boundary. The caller must honor the returned action, content-release flag, and capability restrictions. The project does not replace IAM, network isolation, data classification, secure model selection, or human approval.
What I would test next
The included fixtures are deliberately synthetic. Before adopting this pattern, I would add cases drawn from the application's actual trust boundaries:
- Retrieval context containing sensitive data that never appeared in the user prompt.
- Delegated actions where the caller can read data but cannot write or execute.
- A required integration that times out or returns malformed content.
- A review decision that must suppress every content field while preserving useful evidence.
- A cloud-transformed response that introduces a new local policy violation.
The useful question is not whether one guardrail catches everything. It is whether every layer has a clear job, a bounded failure mode, and a decision the rest of the application is required to honor.
Threat model: https://github.com/fusiontechstrategies/Bedrock-Guardrail-Firewall/blob/main/docs/THREAT_MODEL.md
Testing model: https://github.com/fusiontechstrategies/Bedrock-Guardrail-Firewall/blob/main/docs/TESTING.md
Deployment guide: https://github.com/fusiontechstrategies/Bedrock-Guardrail-Firewall/blob/main/DEPLOYMENT.md
Bedrock Guardrail Firewall is an independent open-source project. It is not affiliated with or endorsed by Amazon Web Services or Microsoft.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article