# agent-trust-assignment-v1

> agent-trust-assignment-v1: 2 Keryn rules for python, typescript, javascript (2 error).

Source: https://keryn.dev/rules/agent-trust-assignment-v1/

2 rules · Keryn Software Licence · rules 0.8.0 · [all packs](https://keryn.dev/rules/)

**How to read a rule**

- **Severity**: How bad the finding is if it is real: `error` fails a default gate, `warning` and `info` do not.

- **Confidence**: **P0** exploitable as written; **P1** dangerous in context; **P2** a heuristic or a posture check: confirm by reading the code.

- **False-positive risk**: **low**: an exact API or flag, so hits are almost always real; **medium**: the pattern is legitimate in many programs, so check each hit; **high**: it finds a lead to confirm, so expect benign hits.

- **Edge**: The relationship the finding sits on. **reaches**: content or traffic gets to a thing; **calls**: one thing invokes another; **reads**: one thing reads from another; **writes**: one thing writes to another; **sends**: data leaves for another party; **grants**: authority is given or left unchecked; **depends_on**: something relies on a component it does not verify; **trusts**: one party believes another without evidence. The boundary it crosses, when there is one: **user->prompt** (untrusted input reaching a prompt); **model->code** (model output reaching code, a shell, a query or a page); **secret->outside** (a secret leaving the trusted side); **supply-chain** (code, models or prompts pulled in from outside).

- **Taxonomy chips**: References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.

## keryn.trust.py.identity-assigned-from-model-output

`error` python data-flow rule python, openai, anthropic, google-genai, langchain

A session, token, identity, privilege or trust field is assigned a value derived from model output or a tool/agent result. Model and tool output is attacker-influenced, so this lets a prompt or a poisoned tool result set the caller's identity or privileges (confused deputy). Derive identity only from a verified principal; never from model or tool output.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-807](https://keryn.dev/rules/?cwe=CWE-807) [CWE-639](https://keryn.dev/taxonomies/cwe/#cwe-639-authorization-bypass-through-user-controlled-key) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI07](https://keryn.dev/taxonomies/owasp-agentic/#asi07-insecure-inter-agent-communication) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Set identity, session, token, privilege and trust fields only from an authenticated principal (verified session, signed token, server-side lookup). Treat model and tool output as untrusted data — never assign it to a security-relevant field.

**References:** [https://cwe.mitre.org/data/definitions/807.html](https://cwe.mitre.org/data/definitions/807.html) · [https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/](https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `web/session_agent.py` and scan it with `keryn scan web --verbose`; the finding below appears.

```python
from anthropic import Anthropic

client = Anthropic()

def resolve_user(request, message_text: str):
    reply = client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=50,
        messages=[
            {"role": "user", "content": f"Extract the account id mentioned here: {message_text}"}
        ],
    )
    request.session.user_id = reply.content[0].text.strip()
    return request.session.user_id
```

Checked with Keryn's browser engine when this page was built: it reports `keryn.trust.py.identity-assigned-from-model-output` at line 14 (error, proof 2). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## keryn.trust.ts.identity-assigned-from-model-output

`error` typescript, javascript data-flow rule typescript, nodejs, openai, anthropic, vercel-ai-sdk, langchain

A session, token, identity, privilege or trust field is assigned a value derived from model output or a tool/agent result. Model and tool output is attacker-influenced, so this lets a prompt or a poisoned tool result set the caller's identity or privileges (confused deputy). Derive identity only from a verified principal.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-807](https://keryn.dev/rules/?cwe=CWE-807) [CWE-639](https://keryn.dev/taxonomies/cwe/#cwe-639-authorization-bypass-through-user-controlled-key) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI07](https://keryn.dev/taxonomies/owasp-agentic/#asi07-insecure-inter-agent-communication) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Set identity, session, token, privilege and trust fields only from an authenticated principal; treat model and tool output as untrusted data.

**References:** [https://cwe.mitre.org/data/definitions/807.html](https://cwe.mitre.org/data/definitions/807.html) · [https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/](https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/)
