# agent-outbound-actions-v1

> agent-outbound-actions-v1: 6 Keryn rules for javascript, typescript, python (4 error, 2 warning).

Source: https://keryn.dev/rules/agent-outbound-actions-v1/

6 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.outbound.model-output-as-message-recipient-js

`error` javascript, typescript data-flow rule resend, nodemailer, sendgrid, twilio, slack

The recipient of an outbound message (email "to", SMS "to", Slack channel) comes from the model's output. A prompt-injected or hallucinated answer then decides who receives the agent's messages, which is the exfiltration and spam path for anything the agent knows. Choose recipients from the task's data or a fixed allowlist and let the model draft only the content.

Confidence **P1**: dangerous in context. False-positive risk **low**: an exact API or flag, so hits are almost always real.

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-441](https://keryn.dev/rules/?cwe=CWE-441) [CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI01](https://keryn.dev/taxonomies/owasp-agentic/#asi01-agent-goal-hijack)

**Fix:** Resolve the recipient from the CRM record, ticket or user session the task is about, compare it with an allowlist of domains or channels, and pass only the model's text as the subject/body; log every send with the resolved recipient.

**References:** [https://resend.com/docs/api-reference/emails/send-email](https://resend.com/docs/api-reference/emails/send-email) · [https://nodemailer.com/message](https://nodemailer.com/message) · [https://www.twilio.com/docs/sendgrid/api-reference/mail-send/mail-send](https://www.twilio.com/docs/sendgrid/api-reference/mail-send/mail-send) · [https://www.twilio.com/docs/messaging/api/message-resource](https://www.twilio.com/docs/messaging/api/message-resource) · [https://api.slack.com/methods/chat.postMessage](https://api.slack.com/methods/chat.postMessage)

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

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

```tsx
import OpenAI from "openai";
import nodemailer from "nodemailer";

const openai = new OpenAI();
const mailer = nodemailer.createTransport({ host: "smtp.example.com", port: 587 });

export async function sendFollowUp(thread: string) {
  const res = await openai.chat.completions.create({
    model: "gpt-4o-mini",
    messages: [
      { role: "user", content: `Who should receive the follow-up for this thread? Reply with an address only.\n${thread}` },
    ],
  });
  const recipient = res.choices[0].message.content;
  await mailer.sendMail({
    from: "support@example.com",
    to: recipient,
    subject: "Following up on your request",
    text: "Thanks for your patience, here is an update.",
  });
}
```

Checked with Keryn's browser engine when this page was built: it reports `keryn.outbound.model-output-as-message-recipient-js` at line 17 (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.outbound.model-output-as-message-recipient-py

`error` python data-flow rule smtplib, resend, sendgrid, twilio, slack

The recipient of an outbound message (email "to", SMS "to", Slack channel) comes from the model's output. A prompt-injected or hallucinated answer then decides who receives the agent's messages, which is the exfiltration and spam path for anything the agent knows. Choose recipients from the task's data or a fixed allowlist and let the model draft only the content.

Confidence **P1**: dangerous in context. False-positive risk **low**: an exact API or flag, so hits are almost always real.

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-441](https://keryn.dev/rules/?cwe=CWE-441) [CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI01](https://keryn.dev/taxonomies/owasp-agentic/#asi01-agent-goal-hijack)

**Fix:** Resolve the recipient from the CRM record, ticket or user session the task is about, compare it with an allowlist of domains or channels, and pass only the model's text as the subject/body; log every send with the resolved recipient.

**References:** [https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.sendmail](https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.sendmail) · [https://resend.com/docs/api-reference/emails/send-email](https://resend.com/docs/api-reference/emails/send-email) · [https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v3-python-code-example](https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v3-python-code-example) · [https://www.twilio.com/docs/messaging/api/message-resource](https://www.twilio.com/docs/messaging/api/message-resource) · [https://api.slack.com/methods/chat.postMessage](https://api.slack.com/methods/chat.postMessage)

## keryn.outbound.model-output-to-crm-record-js

`warning` javascript, typescript data-flow rule hubspot

A CRM record (HubSpot contact, company, deal or custom object) is created or updated from the model's output. Whatever the model inferred, or was injected to write, becomes a business record other people and automations act on: wrong owners, invented deal stages, poisoned notes that later feed another agent's context. Validate each property against its schema and allowlist, and keep the fields the model may write small.

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-20](https://keryn.dev/taxonomies/cwe/#cwe-20-improper-input-validation) [CWE-915](https://keryn.dev/taxonomies/cwe/#cwe-915) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI06](https://keryn.dev/taxonomies/owasp-agentic/#asi06-memory-and-context-poisoning) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Fix:** Build the properties object from a typed schema (zod/pydantic) that lists the writable fields, validate formats (email, enum stages, numeric amounts), reject anything else, and record the model's text in a notes field marked as AI-generated rather than in authoritative fields.

**References:** [https://developers.hubspot.com/docs/api-reference/legacy/crm/objects/contacts/guide](https://developers.hubspot.com/docs/api-reference/legacy/crm/objects/contacts/guide) · [https://developers.hubspot.com/docs/api-reference/legacy/crm/objects/deals/guide](https://developers.hubspot.com/docs/api-reference/legacy/crm/objects/deals/guide)

## keryn.outbound.model-output-to-crm-record-py

`warning` python data-flow rule hubspot

A CRM record (HubSpot contact, company, deal or custom object) is created or updated from the model's output. Whatever the model inferred, or was injected to write, becomes a business record other people and automations act on: wrong owners, invented deal stages, poisoned notes that later feed another agent's context. Validate each property against its schema and allowlist, and keep the fields the model may write small.

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-20](https://keryn.dev/taxonomies/cwe/#cwe-20-improper-input-validation) [CWE-915](https://keryn.dev/taxonomies/cwe/#cwe-915) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI06](https://keryn.dev/taxonomies/owasp-agentic/#asi06-memory-and-context-poisoning) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Fix:** Build the properties dict from a pydantic model that lists the writable fields, validate formats (email, enum stages, numeric amounts), reject anything else, and record the model's text in a notes field marked as AI-generated rather than in authoritative fields.

**References:** [https://developers.hubspot.com/docs/api-reference/legacy/crm/objects/contacts/guide](https://developers.hubspot.com/docs/api-reference/legacy/crm/objects/contacts/guide) · [https://github.com/HubSpot/hubspot-api-python](https://github.com/HubSpot/hubspot-api-python)

## keryn.outbound.model-output-as-payment-amount-js

`error` javascript, typescript data-flow rule stripe

A payment, refund, transfer or payout amount comes from the model's output. A hallucinated figure or an injected instruction then moves money, and Stripe will execute it as written. Compute amounts from your own order and pricing data, bound them, and require a human confirmation above a threshold; the model may propose, never set, the number.

Confidence **P0**: exploitable as written. False-positive risk **low**: an exact API or flag, so hits are almost always real.

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-840](https://keryn.dev/rules/?cwe=CWE-840) [CWE-20](https://keryn.dev/taxonomies/cwe/#cwe-20-improper-input-validation) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI09](https://keryn.dev/taxonomies/owasp-agentic/#asi09-human-agent-trust-exploitation)

**Fix:** Derive amount from the invoice/order record, assert it equals the stored total (or is within the refundable balance), cap it, and route anything above the cap to a human approval step before the Stripe call.

**References:** [https://docs.stripe.com/api/payment_intents/create](https://docs.stripe.com/api/payment_intents/create) · [https://docs.stripe.com/api/refunds/create](https://docs.stripe.com/api/refunds/create) · [https://docs.stripe.com/api/transfers/create](https://docs.stripe.com/api/transfers/create) · [https://docs.stripe.com/api/payouts/create](https://docs.stripe.com/api/payouts/create)

## keryn.outbound.model-output-as-payment-amount-py

`error` python data-flow rule stripe

A payment, refund, transfer or payout amount comes from the model's output. A hallucinated figure or an injected instruction then moves money, and Stripe will execute it as written. Compute amounts from your own order and pricing data, bound them, and require a human confirmation above a threshold; the model may propose, never set, the number.

Confidence **P0**: exploitable as written. False-positive risk **low**: an exact API or flag, so hits are almost always real.

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-840](https://keryn.dev/rules/?cwe=CWE-840) [CWE-20](https://keryn.dev/taxonomies/cwe/#cwe-20-improper-input-validation) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI09](https://keryn.dev/taxonomies/owasp-agentic/#asi09-human-agent-trust-exploitation)

**Fix:** Derive amount from the invoice/order record, assert it equals the stored total (or is within the refundable balance), cap it, and route anything above the cap to a human approval step before the Stripe call.

**References:** [https://docs.stripe.com/api/payment_intents/create?lang=python](https://docs.stripe.com/api/payment_intents/create?lang=python) · [https://docs.stripe.com/api/refunds/create?lang=python](https://docs.stripe.com/api/refunds/create?lang=python)

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

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

```python
import json

import stripe
from openai import OpenAI

client = OpenAI()

def issue_refund(payment_intent: str, ticket_text: str):
    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {"role": "system", "content": "Reply with JSON: {\"cents\": <int>}"},
            {"role": "user", "content": ticket_text},
        ],
    )
    cents = json.loads(resp.choices[0].message.content)["cents"]
    return stripe.Refund.create(payment_intent=payment_intent, amount=cents)
```

Checked with Keryn's browser engine when this page was built: it reports `keryn.outbound.model-output-as-payment-amount-py` at line 18 (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.
