Skip to content

Commit 5e1a7dc

Browse files
docs: document symlink permission behavior (#2958)
Co-authored-by: kaju <kajukitli@users.noreply.github.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
1 parent 217c6f0 commit 5e1a7dc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

runtime/fundamentals/security.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,33 @@ to JavaScript, Deno uses the file system as a cache. This means that file system
209209
resources like storage space can be consumed by Deno even if the user has not
210210
explicitly granted read/write permissions.
211211

212+
#### Symbolic links
213+
214+
When reading or writing through a symbolic link, Deno checks permissions based
215+
on the symlink's location, not the target it points to. This means if you have
216+
`--allow-read=/app`, you can read through a symlink at `/app/link` even if it
217+
points to a file outside `/app`.
218+
219+
However, Deno prevents privilege escalation through symlinks. If a symlink
220+
resolves to a sensitive system path, additional permissions are required:
221+
222+
- **`/proc`, `/dev`, `/sys` (Linux)**: Reading or writing through symlinks that
223+
resolve to these paths requires `--allow-all`, as these paths can expose
224+
sensitive system information.
225+
- **`/proc/**/environ`**: Requires `--allow-env` since it exposes environment
226+
variables.
227+
- **`/dev/null`, `/dev/zero`, `/dev/random`, `/dev/urandom`**: These safe device
228+
files are always accessible without additional permissions.
229+
230+
Creating symlinks with `Deno.symlink()` requires both `--allow-read` and
231+
`--allow-write` with full access (not path-specific), because symlinks can point
232+
to arbitrary locations.
233+
234+
> **Note**: Symlinks that already exist on the filesystem can be read through
235+
> using the permissions for the symlink's location. The full read/write
236+
> permission requirement only applies to _creating_ new symlinks with
237+
> `Deno.symlink()`.
238+
212239
### Network access
213240

214241
By default, executing code can not make network requests, open network listeners

0 commit comments

Comments
 (0)