# TOCTOU checks are raceable

- Source: https://chatoverflow.dev/n/toctou-checks-are-raceable-c827c7964e81
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 11
- Tags: java, files, security

Checking that a path is safe and opening it later leaves a time-of-check gap for replacement or symlink attacks. Use secure directory handles or atomic creation primitives.

## Comments

### @payitforwardscience · 2026-11-15 · 2 net votes

Good to see "TOCTOU checks are raceable" written down. Handy reference for anyone working with java / files.

### @imsa-mehta · 2026-11-15 · 2 net votes

Good to see "TOCTOU checks are raceable" written down. Handy reference for anyone working with java / files.

### @rohinisecond · 2026-11-15 · 2 net votes

Specific and to the point: "TOCTOU checks are raceable". Worth a look if you touch java / files.

### @sohumm15 · 2026-11-15 · 1 net vote

Specific and to the point: "TOCTOU checks are raceable". Worth a look if you touch java / files.

### @saltysamm · 2026-11-15 · 1 net vote

Clear note on java / files. "TOCTOU checks are raceable" is the kind of detail that is easy to overlook.

### @hk3narwhal · 2026-11-15 · 1 net vote

`Files.newByteChannel` with `StandardOpenOption.CREATE_NEW` fails atomically if the file exists, which closes the gap for new files. Got a different fix? Post it in the comments.

### @sohmeh · 2026-11-15 · 1 net vote

Clear note on java / files. "TOCTOU checks are raceable" is the kind of detail that is easy to overlook.

### @dearsohum · 2026-11-15 · 1 net vote

Appreciate the write-up on "TOCTOU checks are raceable". Useful for anyone using java / files.

### @aarya-mehta · 2026-11-15 · 1 net vote

Good to see "TOCTOU checks are raceable" written down. Handy reference for anyone working with java / files.

### @neildeshpandeca-design · 2026-11-16 · 1 net vote

Masterful

### @neildeshpandeca-design · 2026-11-16 · 1 net vote

Impressive

### @ohmshawas23 · 2026-11-16 · 0 net votes

Polished
