Summary
AdGuard Home instances started with the --glinet flag contain a path traversal flaw in the authentication middleware that processes the Admin-Token cookie.
By injecting traversal sequences into the token value, an unauthenticated attacker can bypass authentication and gain full admin access when the token file path is constructed unsafely.
Affected context
The vulnerability affects AdGuard Home deployments launched with the --glinet flag, which enables a GL.iNet-specific authentication middleware.
In this mode, the middleware derives a token file path from the Admin-Token cookie using direct string concatenation without normalizing or constraining the resulting path.
When the application trusts this derived path to validate admin access, a crafted traversal sequence can redirect file reads to attacker-controlled or unrelated locations, undermining the authentication decision.
Exploit preconditions
- Attack surface: HTTP(S) interface of AdGuard Home when started with
--glinet. - Required access: Network reachability to the management interface; no prior authentication required.
- Trigger point: Any request where the attacker can control the
Admin-Tokencookie or header that the GL.iNet auth middleware uses. - Why exploitation is possible: The token file path is built using unsanitized string concatenation, and the resulting path is not restricted to an expected directory or canonicalized before use, enabling directory traversal and token validation bypass.
Why this happens
The core issue maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
The authentication logic in the GL.iNet-specific middleware constructs a filesystem path for an admin token file by directly concatenating a base directory with the user-supplied Admin-Token value.
Because the input is neither normalized nor checked for traversal sequences (such as ../), the resulting path may escape the intended token directory, allowing the code to read arbitrary files and treat their presence or content as proof of admin authentication.
This pattern reflects a broader bug class where trust decisions depend on file paths derived from unvalidated user input.
Potential impact
- Unauthenticated attackers may gain full administrative access to AdGuard Home.
- Attackers could modify DNS filtering rules, blocklists, and upstream DNS settings.
- Adversaries can potentially exfiltrate configuration data and sensitive logs accessible to the AdGuard Home process.
- Compromised instances may be used to redirect or intercept user DNS traffic, enabling phishing or surveillance.
- Attackers could disable security features and prepare follow-on attacks within the local network.
General mitigation guidance
Mitigation typically focuses on constraining and validating any filesystem paths derived from user input and decoupling authentication from arbitrary file reads.
Common defensive patterns include:
- Restricting token file resolution to a fixed, known directory and rejecting any paths that contain traversal sequences or absolute-path markers.
- Using safe path-join utilities that canonicalize and verify the resulting path remains within an expected root.
- Treating header and cookie values as untrusted data, validating them against strict formats (e.g., whitelisting token ID patterns) before they influence filesystem access.
- Designing authentication mechanisms that use opaque, server-generated identifiers (e.g., random tokens or signed cookies) rather than file names derived from client input.
- Running the AdGuard Home process with least-privilege filesystem access so that even if path resolution is flawed, the process cannot read arbitrary sensitive system files.
How teams detect issues like this
Effective detection approaches generally combine code-level analysis with behavioral monitoring:
- Static analysis: Configure rules to flag any use of user-controlled data in filesystem APIs (open/read/write) without prior normalization or directory checks, especially in authentication and authorization code paths.
- Code review signals: During manual review, look for string concatenation when building paths from cookie or header values, missing canonicalization (e.g., no clean/normalize step), and absence of checks that the resolved path resides under a specific directory.
- Policy enforcement: Define secure coding guidelines that require approved helper functions for path construction and forbid direct concatenation of user input into filesystem paths.
- Runtime monitoring: Where feasible, log and monitor unexpected access to token directories or configuration files, especially when paths contain traversal patterns, and trigger alerts for suspicious access attempts.
- Automated code scanning and CI-integrated security linters can help identify these patterns before deployment.

