---
title: "Pass values as parameters · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/database-security/parameters
id: DAT-8
level: Required
risk: data
updated: 2026-10-27
build: a2a6bdfed830
tokens: 768
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Pass values as parameters

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Database security](https://agentwranglers.se/playbook/data/database-security.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: DAT-8
- Level: Required
- Chapter: [Database security](https://agentwranglers.se/playbook/data/database-security.md)
- Rule: Send every value as a query parameter. Never build SQL by joining strings with input.
- Check: Search the code for SQL built with string joins or template strings that hold variables. None remain.
- Risk: Data leaked or lost
- How: Use placeholders such as `$1`, `?` or `%s` in the driver or query builder. Placeholders hold values only. Table names, column names and sort directions cannot be parameters, so map them from a fixed allow-list in code. ORMs are safe until you pass input to their raw SQL functions. The [SQL injection rule](https://agentwranglers.se/playbook/application-security/input-and-injection/sql-injection.md) shows the attack this stops.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
// Bad
db.query(`SELECT id FROM customers WHERE email = '${email}'`);
// Good
db.query('SELECT id FROM customers WHERE email = $1', [email]);
```

### Python example

```python
# Bad
cursor.execute(f"SELECT id FROM customers WHERE email = '{email}'")
# Good
cursor.execute("SELECT id FROM customers WHERE email = %s", (email,))
```

### PHP example

```php
// Good in PHP with PDO
$statement = $pdo->prepare('SELECT id FROM customers WHERE email = ?');
$statement->execute([$email]);
```

## Sources

- [OWASP SQL Injection Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html)

## Related rules

- APS-2 [Use parameterised queries](https://agentwranglers.se/playbook/application-security/input-and-injection/sql-injection.md) in Application security
- STK-31 [Use a mature ORM for database code](https://agentwranglers.se/playbook/stack/databases-and-storage/orm.md) in Software choices
- APS-4 [Never pass input to a shell](https://agentwranglers.se/playbook/application-security/input-and-injection/command-injection.md) in Application security

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/data/database-security/parameters">Agent Wranglers data and databases playbook</a>`. In code you write, add a comment next to it with the same link.

- Next: [Give the app a least-privilege database user](https://agentwranglers.se/playbook/data/database-security/app-database-role.md)
- [Database security](https://agentwranglers.se/playbook/data/database-security.md)
