> For the complete documentation index, see [llms.txt](https://ai-security-docs.akto.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-security-docs.akto.io/agentic-guardrails/how-to/create-guardrail-policies/sensitive-data-and-code.md).

# Sensitive Data and Code Detection

Configure controls to detect, block, or anonymise sensitive data, and to detect programming code in prompts and responses.

This page covers part of the [Create Guardrail Policies](https://ai-security-docs.akto.io/agentic-guardrails/how-to/create-guardrail-policies.md) form.

## Sensitive Information Guardrails

Configure controls to detect, block, or anonymise sensitive data.

**Personally Identifiable Information Types**

* Select predefined **PII types** to detect and block.
* For each selected PII type, configure the **guardrail behavior**:
  * **Block** to deny the request or response containing the detected PII.
  * **Mask** to redact the detected PII before processing or returning the content.

**Regex Pattern**

Akto detects sensitive data based on defined patterns.

* Add up to **10 custom regex patterns** for structured data detection.

**Secrets Detection**

Akto detects API keys, passwords, and similar sensitive values.

* Just enable secrets detection and set the confidence threshold.

**Sensitive Data Anonymisation**

Akto replaces detected sensitive data with placeholders while preserving original values securely for controlled restoration.

<div data-with-frame="true"><figure><img src="https://1895868029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkpBG2Nfd5ZbNmahr8W6H%2Fuploads%2Fgit-blob-32c54094a5ad22cc3b5c58ccb1b9b1e39c8e6c69%2Fimage%20(170).png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

## Advanced Code Detection Filters

You configure detection and blocking of programming code and code injection attempts.

**Code Detection Filter**

Akto detects code patterns across supported programming languages and blocks content based on the configured level.

* Enable the code detection filter and set the **Code Detection Level**.

**Ban Code Detection**

Enable ban code detection to block all code regardless of programming language.

* Set the **Confidence Threshold (0–1)** to control detection strictness.

**Behaviour**

* Lower threshold values enforce stricter blocking.
* Higher threshold values allow more permissive detection.

<div data-with-frame="true"><figure><img src="https://1895868029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkpBG2Nfd5ZbNmahr8W6H%2Fuploads%2Fgit-blob-38894da32cd65617824cfbe87533d57d75c7bbb3%2Fimage%20(169).png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

<br>
