# Sinkmark

> Use when reviewing Python source for injection bugs, especially SQL built from strings, eval or exec of input, shell=True, pickle or unsafe yaml loads. Traces web input to dangerous calls across functions in the same file. Local only.

- Skill: `codejunkie99/sinkmark` (Agent Skill)
- Install (CLI): `npx get-skill add codejunkie99/sinkmark`
- Raw SKILL.md: https://api.skillmd.com/api/skills/codejunkie99/sinkmark/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: codejunkie99 (https://skillmd.com/u/codejunkie99)
- Updated: 2026-11-16
- Page: https://skillmd.com/skills/codejunkie99/sinkmark

---


# sinkmark: find dangerous sinks in source

## job
find places where outside input can reach a call that runs code, runs SQL, or runs a shell, and report each one once.

## gap it targets
- evidence (fixture): in our fixture run, a popular python ruleset reported `eval` of a query arg but missed `query = "... '" + user_id + "'"` followed by `cur.execute(query)`, where `user_id` came from `request.args` in another route.
- evidence (fixture): the same `eval` call came back twice under two rule IDs. this skill reports one finding per sink.
- hypothesis: starting from sinks and walking back to sources misses fewer bugs than matching whole patterns, at the cost of some medium-confidence noise.

## inputs
- a repo path. v1 scope is `.py` files. other languages: report "not covered" instead of guessing.
- optional: a list of changed files, to focus on a diff.

## method
1. list python files, skipping `venv`, `.venv`, `site-packages`, `node_modules`, `build`, `dist`.
2. find sinks with grep first, then read each hit in context:
   - SQL: `.execute(`, `.executemany(`, `.raw(`, `text(` from SQLAlchemy, `cursor.mogrify(`
   - code: `eval(`, `exec(`, `compile(`, `__import__(`
   - shell: `os.system(`, `os.popen(`, `subprocess.*(..., shell=True)`
   - deserialize: `pickle.loads(`, `pickle.load(`, `yaml.load(` without `SafeLoader`, `marshal.loads(`
3. for each sink, look at the argument. is it built with `+`, `%`, `.format(`, or an f-string, or is it a variable assigned from one? if yes, it is a candidate.
4. walk back: which function holds it, who calls that function in this file, and do any callers pass `request.args`, `request.form`, `request.json`, `request.values`, `request.cookies`, `request.headers`, `request.GET`, `request.POST`, a FastAPI path or query param, `sys.argv`, or `input()`?
5. check for a real fix on the path: SQL params passed as a separate tuple or dict, `ast.literal_eval` instead of `eval`, `shlex.quote` with a list argv and no shell, `yaml.safe_load`. a regex check or `str()` is not a fix.
6. set confidence: high when a source reaches the sink, medium when the sink takes a string-built value with no source found, low when the value could be constant but you could not prove it.
7. one finding per sink line plus CWE. if two checks hit the same line for the same CWE, merge them.

## what counts as a finding
- a SQL, code, shell, or deserialize sink whose argument is built from non-constant strings.
- not a finding: constant SQL with bound parameters, `eval` of a literal you can see, test files that only exercise a sanitizer (mark `info` if unsure).

## output
```json
{"command":"sinkmark","rule_id":"ks.py.sqli.string-built-query","kind":"sast","severity":"high","confidence":"high","cwe":["CWE-89"],"title":"SQL built from request input reaches execute","location":{"path":"src/app.py","start_line":15,"end_line":16},"evidence":"query built with + from user_id; user_id from request.args in user()","sources":["sinkmark"],"status":"open"}
```
write all findings as a JSON array, and SARIF 2.1.0 if asked.

## today vs later
- today: grep plus reading, plus any static analyzer already installed. treat their output as extra leads, not the answer, and still do steps 3 to 5 yourself.
- once the keelsec engine exists: `keelsec sinkmark <path> --format json` does the AST walk and call graph; you only triage.

## stop and scope
- read only. never run the app to "test" a sink. live confirmation belongs to `lastproof`, on an owned staging target.
- say clearly which languages and folders you did not cover.

