# Source review: entry point to protected operation

Trace attacker control and authorization through handlers, services, queues, and sensitive operations; promote only reachable violations of a stated invariant.

## Investigation sequence

1. State invariant
2. Find entry
3. Trace transformations
4. Check guards
5. Exercise interface
6. Retest sibling paths

## Used in these playbooks

[OSS & self-hosted](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/oss.html) · [Web & API](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/web-api.html) · [Mobile](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/mobile.html) · [Desktop & extensions](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/desktop.html) · [AI, agents & MCP](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/ai.html)

## Write the invariant first

Choose a business rule precise enough to falsify: “a member can export documents only from a project where membership is currently active.” Record actor, object, operation, tenant, and when authorization must hold. A suspicious function becomes useful when you identify who can reach it and what protected state it changes. Reuse the [authorization matrix](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/modules/authz-matrix.html) for principal/object combinations and [injection tracing](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/modules/injection-tracing.html) for interpreter-specific input handling.

Start forward at a real interface: HTTP route, websocket event, CLI argument, uploaded project, plugin callback, or queue producer. Then work backward from the sensitive read, write, process invocation, parser, or credential use. Join the two traces; unresolved dynamic dispatch is an explicit gap. Check route registration and feature gating rather than assuming a named handler is exposed.

## A worked asynchronous trace

The following is a hypothetical review worksheet, not a finding against a named project.

| Hop | Value or context | Question to resolve |
|---|---|---|
| `POST /exports` | Authenticated member A supplies `document_id` | Does the route check document membership or only login? |
| `ExportService.create` | A job stores `document_id`, `requested_by` | Is the trusted tenant copied from the session or accepted from input? |
| Queue serialization | Job survives after request completes | Can another low-trust producer alter the fields? |
| `run_export(job)` | Worker reloads document by ID | Is current membership enforced at execution time? |
| Object storage write | Export receives a download reference | Who can fetch it, and can authorization expire? |

A useful candidate is “worker rehydrates an object globally after a tenant-scoped request.” Confirm whether the earlier guard binds the *same* immutable identifier, whether membership revocation should affect queued jobs, and whether the output is actually accessible. Business requirements may deliberately snapshot permissions; document that distinction rather than treating every delayed check as defective.

## Local search and modeling cheat sheet

Examples inspect a reviewed local repository. Patterns are leads, not a complete inventory. Place evidence outside the scan root; prepare local rules before offline/private-code analysis.

```bash
rg -n --hidden -g '!.git' \
  'route\(|router\.|websocket|add_task|enqueue|\.delay\(' ./repo
rg -n --hidden -g '!.git' \
  'pickle\.loads|yaml\.load|subprocess\.|child_process|exec\(' ./repo
semgrep scan --oss-only --config ./rules --metrics=off \
  --disable-version-check --json \
  --output ./evidence/source-leads.json ./repo
```

The Semgrep command uses reviewed local rules and the OSS engine. Inspect stderr, skipped files, and scan completion; an empty result with parser failures is not a clean audit. Rule licenses and engine capabilities are separate concerns. [Semgrep CLI reference](https://docs.semgrep.dev/cli-reference).

Model sources, propagation, context-specific sanitizers, and sinks. A path validator does not sanitize a shell argument; a role check does not validate serialized data. Custom wrappers can hide a source or sink from default rules. Create one vulnerable fixture and one safe sibling to validate your model. Static taint analysis does not automatically establish tenant policy or full runtime reachability. [Semgrep taint model](https://docs.semgrep.dev/writing-rules/data-flow/taint-mode/overview).

## Prove the boundary through supported use

Instrument the local application to log identifiers, decisions, and function names without credentials. Reproduce from the ordinary interface with synthetic accounts. Keep four observations together: allowed own-object request; denied or expected-to-deny foreign-object request; actual protected effect; resulting output access. Repeat without instrumentation changing security behavior. If only an internal helper is callable, qualify the finding as a library/caller-contract issue until a consumer path is established.

Inspect alternate callers after proving one flaw: bulk API, export service, websocket subscription, scheduled task, and administrative UI may reuse the same operation with different guards. Group equivalent paths by root cause and record tested variants. Do not inflate one shared defect into five independent findings.

## Completion and report threshold

- [ ] Invariant identifies actor, object, operation, and trust boundary.
- [ ] Attacker-controlled field is tracked through transformations and aliases.
- [ ] Every guard is evaluated with concrete fixture values.
- [ ] Feature, edition, role, and configuration prerequisites are explicit.
- [ ] Real interface reproduces the protected effect beside an authorized control.
- [ ] Safe sibling and patch retest preserve legitimate behavior.

Submit the smallest connected argument: entry point → attacker control → ineffective boundary → sensitive operation → demonstrated impact. A sink search, scanner trace, or direct helper call alone belongs in the hypothesis queue.

## Vulnerability reverse references

- [Hard-coded product credentials](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/hardcoded-credentials.html) — A reusable credential is embedded in source, history, a release, or a default configuration. Distinguish a shared built-in credential from an accidentally committed deployment credential when assigning the weakness.
- [Unsafe object deserialization](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/unsafe-deserialization.html) — Untrusted bytes reach a format that can instantiate behavior-bearing objects or invoke code, such as Python pickle, without a sufficient trust boundary.
- [JavaScript prototype pollution](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/prototype-pollution.html) — An attacker-controlled property path changes inherited object state, which can affect unrelated objects and security-sensitive consumers.
- [Out-of-bounds memory write](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/out-of-bounds-write.html) — A native component writes beyond an allocated object because length, index, or allocation assumptions do not agree.
- [Use after free in a public API or parser lifecycle](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/use-after-free.html) — Code uses an object after its lifetime has ended, often across callbacks, error handling, reference counting, or asynchronous operations.
- [Integer overflow affecting allocation or bounds](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/integer-overflow.html) — Input-derived arithmetic wraps or overflows so the checked size, allocation size, and later operation refer to different effective values.
- [Regular-expression denial of service](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/regex-dos.html) — An attacker-controlled string makes the chosen regular-expression engine perform excessive backtracking or other disproportionate matching work.
- [Predictable temporary files and unsafe creation](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/insecure-temporary-files.html) — A component creates or reuses temporary files in a way that permits another local principal to precreate, replace, read, or redirect sensitive operations.
- [Untrusted executable, library, or module search path](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/untrusted-search-path.html) — A program resolves an executable/library/module from an attacker-writable search location instead of the intended trusted component.
- [Firmware contains a reusable shared authentication credential](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/firmware-shared-credentials.html) — An attacker-accessible firmware artifact embeds a credential that grants protected access, potentially across multiple devices.
- [Exposed repository or history secret](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/exposed-repository-secret.html) — Source, history, or a published artifact exposes a credential outside its intended audience.
- [Sensitive data in errors, debug routes, or generated files](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/sensitive-error-disclosure.html) — An error or debug output crosses a confidentiality boundary by revealing protected state.
- [Predictable security token or capability identifier](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/weak-security-token-randomness.html) — A security token relies on randomness that does not meet its unpredictability requirement.
- [Password storage without an adequate adaptive hash](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/password-storage-weak-hash.html) — A password verifier has insufficient computational cost for its supported threat model.
- [Encrypted data accepted without integrity authentication](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/crypto-authentication-missing.html) — A protected data format permits security-relevant changes that are not detected before use.
- [SAML assertion signature, audience, or response binding failure](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/saml-assertion-trust.html) — The service provider trusts an assertion whose signature or authentication context is not valid for the receiving flow.
- [Untrusted model artifact reaches executable deserialization or custom code](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities/model-artifact-unsafe-loading.html) — An attacker-controlled artifact reaches a loader whose execution trust exceeds the uploader's intended data-only authority.
