|
| 1 | +# Ruff and ty CLI threat model |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Ruff is a Python linter and formatter. ty is a Python type checker. Their commands and native |
| 6 | +libraries run with the user's or CI worker's permissions. |
| 7 | + |
| 8 | +A behavior is a security issue only when an independent attacker controls a concrete input, Ruff or |
| 9 | +ty uses it to cross a boundary defined below, and the crossing gives the attacker new power or harms |
| 10 | +a protected asset. Trusted-machine compromise, intended behavior, and correctness defects that give |
| 11 | +an attacker no new power are not security issues. |
| 12 | + |
| 13 | +Editors, playgrounds, and repository automation have [separate models](threat-models.md). |
| 14 | + |
| 15 | +## Trust boundaries and assumptions |
| 16 | + |
| 17 | +- **Attacker-controlled:** project files used during analysis, including source code, project |
| 18 | + configuration, and dependency source code. |
| 19 | +- **Trusted local input:** the operating system, installed programs, environment variables, `PATH`, |
| 20 | + caches, user configuration, explicit command-line choices, and user-managed filesystem state that |
| 21 | + the attacker cannot change. |
| 22 | + |
| 23 | +## Security invariants |
| 24 | + |
| 25 | +- **Code Execution:** Analysis must not execute user-supplied code. |
| 26 | +- **Configuration and file discovery:** Ruff's `--isolated` must ignore configuration files. Imports, |
| 27 | + configuration extensions, and symlinks may lead outside the project; reading those files is |
| 28 | + expected. |
| 29 | +- **Edits and cleanup:** Formatting, fixes, ignore insertion, and cache cleanup may change only the |
| 30 | + targets selected by that operation. Formatting with `--check` must preserve source files. |
| 31 | + Incorrect fixes are ordinarily correctness bugs. |
| 32 | +- **External programs:** ty's uv integration is disabled by default. When enabled, it uses the |
| 33 | + executable selected by `UV` or `PATH` for workspace metadata and script environments. Script |
| 34 | + synchronization may install dependencies. |
| 35 | +- **Output:** Diagnostics may contain source text and paths. They must be encoded for the selected |
| 36 | + terminal or CI format so that attacker-controlled text cannot inject commands or active content. |
| 37 | +- **Availability:** Failing or slow analysis is a correctness or performance bug. |
| 38 | + A security issue requires repeatable, disproportionate resource use that materially disrupts |
| 39 | + the developer's machine or CI worker beyond the failed analysis. |
| 40 | + |
| 41 | +## Severity calibration |
| 42 | + |
| 43 | +- **Critical:** With few prerequisites and safe defaults, analysis input compromises credentials |
| 44 | + with broad permissions or causes widespread file damage without first compromising a trusted host. |
| 45 | +- **High:** A demonstrated path from analysis input to arbitrary native execution, substantial |
| 46 | + disclosure of private data, or destructive filesystem access beyond the requested operation. |
| 47 | +- **Medium:** A limited unauthorized read or write, or bypass of an execution restriction with |
| 48 | + limited effect. |
| 49 | +- **Low:** A narrow disclosure or safety gap across a real boundary with limited practical impact, |
| 50 | + or reliable resource exhaustion affecting the developer's machine or CI worker. |
| 51 | +- **Informational:** A genuine security concern with negligible current impact. |
0 commit comments