# Predictable temporary files and unsafe creation

A component creates or reuses temporary files in a way that permits another local principal to precreate, replace, read, or redirect sensitive operations.

**Candidate CWE:** [CWE-377](https://cwe.mitre.org/data/definitions/377.html)

## Test hypothesis

In a local multi-user fixture, inspect path selection, creation atomicity, permissions, and link handling. Use an owned synthetic destination and a harmless marker to test precreation or replacement. Establish the attacker's directory permissions and the victim's actual privilege.

## Evidence required

Temporary path construction, creation flags/mode, distinct actor identities, directory permissions, protected synthetic effect, and safe exclusive-creation control. For races, preserve a repeatable bounded sequence and observed success count.

## Rule out false positives

Secure atomic creation in a private directory, restrictive file permissions, caller-owned paths with no privilege difference, or a hypothetical race with no attainable scheduling/permission conditions.

## Playbook and command references

- [Source review: entry point to protected operation](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/modules/source-dataflow.html) — Trace attacker control and authorization through handlers, services, queues, and sensitive operations; promote only reachable violations of a stated invariant.
- [OSS lab: pin, install, prove, reset](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/modules/oss-lab-reproduction.html) — Turn an eligible release into a repeatable synthetic environment with preserved versions, realistic controls, and an explicit reset recipe.

[Find the associated command snippets](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/commands.html?q=Source%20review%3A%20entry%20point%20to%20protected%20operation)

## Referenced by these target playbooks

[OSS & self-hosted](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/oss.html) · [Desktop & extensions](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/desktop.html) · [Mobile](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/mobile.html) · [Cloud & containers](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/cloud.html) · [Hardware & firmware](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/hardware.html)

## Report checklist

- [ ] Capture the affected version, configuration, identities, and object ownership.
- [ ] Preserve a valid baseline and a negative control.
- [ ] Reproduce the forbidden data access, action, or state change on controlled fixtures.
- [ ] Explain the intended security rule and why the observed behavior violates it.
- [ ] State prerequisites, uncertainty, cleanup, and the smallest demonstrated impact.

## Conditional ATT&CK mapping

No direct ATT&CK mapping selected. Record the weakness and demonstrated impact without forcing an adversary-behavior classification. See the [mapping guide](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/attack.html).

## Primary references

- [MITRE CWE-377](https://cwe.mitre.org/data/definitions/377.html)
- [Python tempfile API](https://docs.python.org/3/library/tempfile.html)

[Back to the complete vulnerability catalog](https://bug-bounty-field-manual.kmahshooq.chatgpt.site/vulnerabilities.html)
