Jun 20, 2026·7 min read·30 visits
Discrepant globbing behaviors in Pydantic Settings allow directory traversal and symlink resolution bypasses, leading to arbitrary local file read and infinite loops.
A directory traversal and symlink following vulnerability exists in Pydantic Settings when using the NestedSecretsSettingsSource with nested subdirectory lookups enabled. An attacker capable of writing to the secrets directory can bypass size limitations, read arbitrary host files, or cause a denial-of-service condition via cyclic symlinks.
The library pydantic-settings is a widely adopted configuration management framework for Python applications, building upon Pydantic to parse environment and filesystem values. Inside this framework, the NestedSecretsSettingsSource class handles the resolution of secrets from a designated directory, mapping on-disk files to configuration properties. When the secrets_nested_subdir option is enabled, the library reads these subdirectories recursively, which maps complex directory hierarchies into nested model structures.
The security model of the secrets directory loader assumes that files are strictly retrieved from the directory designated by the secrets_dir parameter. To prevent uncontrolled system resource consumption, developers can define a size ceiling using the secrets_dir_max_size setting. This check is designed to prevent the application from reading arbitrarily large files into active process memory during startup.
However, a serious security discrepancy exists within the directory-traversal and file-scanning operations of this component. The library fails to validate whether resolved file paths remain within the boundary of the configured root directory. Consequently, local privilege escalation or arbitrary file disclosure can occur if an attacker can manipulate files or insert symbolic links in the target directory.
The core vulnerability arises from a logic discrepancy between the validation routines and the file loading mechanisms. During the validation phase, NestedSecretsSettingsSource executes a size check using pathlib.Path.glob('**/*') to verify that the total directory size does not exceed the limit. In standard Python runtime environments, pathlib.Path.glob does not descend into symbolic links that reference external directories.
Directly following this check, the loading phase is initiated using glob.iglob with recursive=True to retrieve configuration keys. Unlike the validation routine, glob.iglob automatically follows symbolic links pointing to external directories on the host filesystem. This inconsistent behavior allows symbolic links to bypass the maximum file size validation checks entirely.
An attacker can exploit this behavior by placing a directory symbolic link pointing to a sensitive system folder inside the designated secrets directory. The size check calculates the symbolic link size as zero bytes, bypassing the secrets_dir_max_size safety boundary. The loader subsequently resolves the link and reads the targeted external files into the application memory space.
In addition to information leakage, this logic flaw exposes the application to a denial-of-service condition. Because glob.iglob does not maintain a history of visited directories, cyclic symbolic links trigger infinite recursive loops during loading. This behavior leads to excessive CPU and memory consumption, eventually crashing the application process.
To analyze the implementation discrepancy, we examine the vulnerable code path inside nested_secrets.py. The validation step computes the total directory size using path.glob:
# Vulnerable validation implementation
secrets_dir_size = sum(f.stat().st_size for f in path.glob('**/*') if f.is_file())Directly after the size validation check, the file loading pass uses the standard glob.iglob function:
# Vulnerable file loader implementation
return {
str(p.relative_to(path)): p.read_text().strip()
for p in map(Path, iglob(f'{path}/**/*', recursive=True))
if p.is_file()
}The patch resolves this discrepancy by replacing the differing glob libraries with a custom directory walker named _iter_secret_files. This custom walker explicitly tracks visited directories in a set named seen_dirs and computes canonical paths using Path.resolve(). If a directory has already been visited, the loop terminates immediately, preventing cyclic symlink loops.
# Patched recursive walker preventing traversal and cyclic loops
seen_dirs: set[Path] = set()
def walk(directory: Path) -> Iterator[Path]:
resolved_dir = directory.resolve()
if resolved_dir in seen_dirs:
return
seen_dirs.add(resolved_dir)
try:
entries = sorted(directory.iterdir())
except OSError:
return
for entry in entries:
resolved = entry.resolve()
if resolved.is_dir():
if resolved == path or path in resolved.parents:
yield from walk(entry)
elif resolved.is_file() and path in resolved.parents:
yield entryBoth the size validation engine and the loader call this unified iterator, ensuring that the processed file sets are identical. Symbolic links pointing to files outside the designated secrets_dir are rejected because the condition path in resolved.parents is not met. This prevents out-of-bounds files from contributing to the size computation or being read during initialization.
Exploitation requires that an attacker have sufficient local permissions to create or modify files inside the configured secrets_dir path. This scenario frequently occurs in multi-tenant environments, shared hosting platforms, or systems where container volumes are exposed to unprivileged users. The attacker must also target an application with secrets_nested_subdir enabled on NestedSecretsSettingsSource.
To initiate the exploit, the attacker maps out the physical layout of the application's configuration directory. They inject a symbolic link pointing to a sensitive file or directory located elsewhere on the host machine:
ln -s /etc/passwd secrets_dir/database_configWhen the host application initializes, the size validation check processes database_config as a zero-byte entry, bypassing the limit. The loader then processes the virtual relative path database_config and executes p.read_text().strip() on the target /etc/passwd. The contents of the target file are loaded directly into the Pydantic schema parameter assigned to the database configuration.
To execute a denial-of-service attack, the attacker constructs a self-referential directory structure. By running ln -s ../ secrets_dir/loop, the loader enters an infinite traversal cycle. This recursion consumes execution resources, causing CPU exhaustion and memory inflation that terminates the parent process.
The confidentiality impact of this vulnerability is moderate depending on the access controls of the execution environment. If the application runs under a privileged user context, an attacker can extract sensitive system files such as password databases or service tokens. This information leakage occurs silently during startup, making detection difficult without structural filesystem auditing.
The integrity of file loading mechanisms is compromised because the size constraints set by developers are bypassed. Large external files are loaded into memory without throwing size validation exceptions, which can result in heap fragmentation or out-of-memory errors. This behavior invalidates the effectiveness of configuration safeguards.
Availability threats are high due to the lack of cyclic path detection in the older loader implementation. A single cyclic symbolic link can cause a persistent denial-of-service state on application startup. In automated container environments, this crash behavior can trigger infinite restart loops, leading to cluster instability.
The CVSS score of 5.3 reflects the requirement of local filesystem write privileges to execute the attack. However, in containerized deployments or cloud infrastructure where secrets directories are shared across pods, this vulnerability can serve as a vector for container escape or lateral movement.
The definitive remediation path is upgrading the pydantic-settings dependency to version 2.14.2 or later. This version introduces the unified custom directory walker that restricts symbolic links and prevents recursive loops. Upgrading can be verified by checking that _iter_secret_files is present in the NestedSecretsSettingsSource class.
If upgrading is not immediately possible, disabling nested subdirectory configuration is an effective workaround. Setting the parameter secrets_nested_subdir=False stops the recursive scanning behavior and prevents the loader from descending into directory symbolic links. This configuration effectively neutralizes the primary traversal vector.
Additionally, administrators should apply strict filesystem permissions to the secrets_dir path. Restricting directory access with a 0700 permission mask ensures that only the application runtime user can read or write configuration files. This permission restriction prevents lower-privileged local users from injecting malicious symbolic links.
Finally, deployment workflows should integrate automated filesystem scanning to identify illegal symbolic links in configuration directories. Running file auditing commands during container startup can detect symlinks pointing to paths outside the deployment root. If external links are detected, the container initialization sequence should be aborted.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L| Product | Affected Versions | Fixed Version |
|---|---|---|
pydantic-settings Pydantic | >= 2.12.0, < 2.14.2 | 2.14.2 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-59 |
| Attack Vector | Local |
| CVSS Score | 5.3 |
| Exploit Status | Proof-of-Concept |
| EPSS Percentile | N/A |
| CISA KEV Status | Not Listed |
| Affected Component | NestedSecretsSettingsSource |
The application follows symbolic links to files outside the designated directory structure, leading to unauthorized access to files.
A critical heap out-of-bounds (OOB) write vulnerability exists in the Linux kernel's IPv6 RPL (Routing Protocol for Low-Power and Lossy Networks) Segment Routing Header (SRH) processing logic. The vulnerability is located within net/ipv6/exthdrs.c, specifically in the ipv6_rpl_srh_rcv function. Under specific circumstances, when a packet containing a compressed RPL Source Routing Header is processed, segment swapping can reduce the common-prefix length, causing the recompressed header to grow. Because the kernel fails to validate available headroom on intermediate segments, a buffer underflow occurs during skb_push. This leads to an integer wrap in the MAC header offset pointer during MAC header rebuilding, causing a 14-byte out-of-bounds memory write roughly 64 KiB past the socket buffer.
CVE-2026-58263 is a high-severity Mutation Cross-Site Scripting (mXSS) vulnerability affecting Jodit Editor prior to version 4.12.28. The flaw exists in Jodit's built-in clean-html sanitizer plugin, which fails to securely parse and sanitize nested elements containing foreign namespaces like MathML and SVG. Attackers can bypass sanitization by smuggling malicious payload elements inside rawtext container tags like style inside a MathML node, leading to DOM mutation and unauthenticated arbitrary script execution in the context of the user's browser session.
Jodit Editor versions prior to 4.13.6 are vulnerable to client-side Cross-Site Scripting (XSS). The clean-html plugin's sanitization routine performs case-sensitive lookups against uppercase-only element blacklists. When processing XML-based foreign namespaces such as SVG or MathML, DOM engines preserve the lowercase format of tags. Because Jodit's denyTags check fails to normalize tag casing, malicious script blocks nested inside foreign namespace elements completely bypass validation and serialize directly into the editor output.
A critical code injection vulnerability exists in Savon, a widely used SOAP client library for Ruby, prior to version 2.17.2. The vulnerability resides within the Savon::Model.all_operations module, where operation names fetched from a target Web Services Description Language (WSDL) document are dynamically evaluated via module_eval without sanitization. An attacker capable of manipulating the target WSDL document (e.g., through Man-in-the-Middle attacks, DNS hijacking, or Server-Side Request Forgery) can execute arbitrary Ruby code in the context of the parent application process.
An integer conversion overflow vulnerability exists in the XCF decoder of ImageMagick before version 6.9.13-51 and 7.1.2-26. The issue arises from mixed-type arithmetic that promotes calculation results to floating-point representations, causing an undefined cast back to integer. Under optimizing compilers, this undefined behavior results in bounds checks being bypassed, allowing out-of-bounds heap reads.
An authenticated file upload validation bypass vulnerability exists in the REDAXO CMS Mediapool addon in versions 5.18.2 through 5.21.0. Under permissive web server configurations, this allows authenticated users with media upload privileges to achieve remote code execution via multi-segment extension file uploads.