All lessons Leer en español

Security in depth · Unit 22 · Lesson 4 of 44

Directories control names and traversal

Separate listing a directory from resolving a file within it.

3 minreadyShort lesson

Helpful before thisLinux privilege escalation

See all lessons in this topic

After this lesson you can

  • Distinguish directory read/search rights from permissions on file contents.

One idea. One situation. One reasoned decision.

How it works

Directory permissions describe operations on a namespace. Read permits listing names; search, represented by execute, permits traversing or looking up entries. Write relates to changing entries, normally together with search permission. File contents have their own permissions. This distinction explains why protecting only a file’s write bit may not adequately protect its location or replacement. Evaluate the containing directories as well as the file.

Directory entries → File location → File contentsDirectory entriesFile locationFile contents
Follow the relationship: Directory entries → File location → File contents.

Read the supplied record

Assume ordinary discretionary access checks, no privileged override, no existing open handle, and no alternate path to the file.

Resource Reviewer’s rights
Project directory Read, without search
A known report inside it Read

The reviewer may obtain the directory’s names, but opening the report through this pathname still requires search permission on the directory. Knowing the filename does not supply that permission. The file’s own read grant answers a later, separate question.

For maintenance, also separate editing file contents from adding, renaming, or removing directory entries. Directory write and search are relevant to entry changes; sticky-directory rules and other controls may impose further restrictions. Do not infer permission to perform every directory operation from a single successful file read.

A useful review identifies each required operation along the path and states which evidence supports it.

The key distinction: Control of directory entries and control of file contents are separate.

Check yourself

No timer. No penalties. Read the explanation and try again whenever you like.

  1. The reviewer can list a directory but lacks search permission on it. A file inside grants the reviewer read access. With no overrides or alternate access path, can the reviewer open that pathname?

    Show the answer

    Correct answer: No: pathname resolution still needs directory search permission. The file-level read grant is only one required condition. The specified path cannot be resolved through this directory.

Try it

  • WriteExplain why a reviewer might see a filename yet fail to open that file. Name the directory operation and file operation separately, using the fictional record.
References