A table in osquery that exposes file metadata such as path, ownership, timestamps, permissions, and size. It is useful for locating and characterising files across endpoints, but it depends on path scoping and careful query design to avoid expensive recursion and incomplete results.
How the Osquery File Table Works
The osquery file table turns file system state into queryable rows, letting analysts inspect paths, ownership, timestamps, permissions, and size with SQL-like filters. That makes it useful for endpoint triage, inventory, and hunting, but it is only as accurate and efficient as the scope you define.
The important operational idea is that this table does not magically enumerate an entire host safely by default. Path scoping, recursion depth, and file-system layout all affect what you see, how long the query runs, and whether you accidentally create noise or miss material evidence. When used well, it is a precise way to answer questions about file presence and metadata across large fleets.
That precision is most useful when paired with other endpoint evidence. File metadata can show that something exists, when it changed, who owns it, and whether it has unusual permissions, but it does not tell you whether the file is benign, malicious, or simply irrelevant without surrounding context such as process, hash, persistence, or configuration data.
What You Can Learn From File Metadata
The file table is strongest when you need to characterise files rather than read their contents. Path, mode, owner, group, size, and timestamps help distinguish normal system artifacts from suspicious changes, especially when you are looking for unexpected binaries, writable configuration files, or files planted in unusual locations.
Those attributes are also useful for drift detection. A file that appears in an endpoint baseline with a modified timestamp, changed permissions, or an unexpected owner can indicate software updates, administrative activity, or tampering. The table helps you separate those possibilities before moving to deeper investigation.
The Ultimate Guide to NHIs is relevant here because file-based leakage is a common way secrets and credentials surface outside intended controls, and path-scoped inventory work often becomes part of that visibility effort. For the same reason, endpoint file checks are often paired with broader host investigations such as the Emerald Whale breach, which shows how exposed config files can become a source of stolen secrets.
Why Query Design Matters
File-table queries are highly sensitive to scope. Broad recursion across large directory trees can be expensive, slow, and operationally disruptive, while narrow scoping can miss nested paths or files that matter. Good query design is therefore part of the value of the table, not just a performance concern.
Path filters, recursion limits, and targeted globs determine whether the table answers a focused question or turns into an endpoint-wide crawl. That matters because the same query that is acceptable on a lab host may be too expensive or too incomplete at enterprise scale, especially when repeated across many endpoints in a scheduled collection cycle.
In practice, the right query is the one that matches the investigative intent. If you are validating a known directory, looking for a specific artifact, or checking for a change in permissions, keep the scope narrow and the output relevant. If you need broad discovery, treat the resulting cost and coverage gaps as part of the analysis rather than an implementation detail.
Common Use Cases and Limitations
The file table is commonly used for incident response, asset verification, compliance checks, and hunting suspicious persistence or staging artifacts. It is particularly helpful when you need fast metadata over many endpoints without mounting remote shares or relying on interactive access.
Its main limitation is that metadata alone is not a verdict. A file can appear normal while still being malicious, and a suspicious path can contain legitimate software. The table also depends on the operating system, permissions, and how the query is written, so incomplete results are a real possibility if the scope is too strict or the endpoint cannot traverse the targeted path.
For that reason, the file table is best treated as a discovery and characterisation tool. It helps you decide what deserves deeper inspection, but it should not be the only evidence source when assessing compromise, persistence, or unauthorised change.
Risk and Threat Considerations
File-table queries can create two distinct problems: they can miss important files because the scope is too tight, or they can become expensive and noisy because the scope is too broad. On real endpoints, that trade-off affects both detection quality and operational stability.
Failure mechanism: Recursive path selection, weak filtering, or poor assumptions about directory layout can produce incomplete coverage or excessive filesystem traversal, leaving investigators with false confidence or unnecessary performance cost.
Impact: Analysts may overlook suspicious files, misread file-state evidence, or create avoidable load during fleet-wide collection.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 address the attack and risk surface, while CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| CIS Controls v8 | CIS 8 — Audit Log Management | File-table queries support endpoint visibility and investigation. |
| CIS 4 — Secure Configuration of Enterprise Assets and Software | File metadata checks help detect unexpected paths, permissions, and drift. | |
| Recommendation — Use endpoint query evidence to improve file-state visibility and investigation coverage. Validate file paths and permissions against secure configuration baselines. | ||
| NIST CSF 2.0 | DE.CM — Security Continuous Monitoring | The table is used to continuously observe endpoint file-state changes. |
| ID.AM — Asset Management | File inventory and characterisation support identifying endpoint assets and artifacts. | |
| Recommendation — Apply continuous monitoring to detect file-state drift and suspicious modifications. Maintain accurate asset inventories using scoped file-state collection. | ||
| OWASP Non-Human Identity Top 10 | NHI-02 — Secrets and Credential Management | File paths often expose secrets, config files, and credential material on endpoints. |
| Recommendation — Search for exposed secrets in files and move them into managed secret storage. | ||
Practitioner Guidance
What to watch for: Use the file table when the question is about file state, not file content, and treat the query itself as part of the control surface. Narrow the path first, then expand only when the additional coverage is worth the performance cost and the risk of incomplete results.
Practitioner takeaway: The best osquery file-table queries are specific enough to be fast and broad enough to be trustworthy.
Related resources from NHI Mgmt Group
- How should security teams decide whether a new osquery table is worth adding to an endpoint fleet?
- What are the signs that an osquery table design is too privacy invasive for production use?
- What should teams do when a new osquery table needs review and approval from maintainers?
- How should security teams use osquery file queries without creating expensive recursive scans?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on September 19, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org