user_ldap app logs user passwords in the log file on level debug
When Nextcloud uses LDAP authentication and debug logging is enabled, the user_ldap app writes the plaintext password to the log file during ldap_bind. A local administrator with access to the log file could read user passwords.
- Triaged in under an hour
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 3 months
Summary by the program
Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-35p6-4992-w5fr
The report
Summary:
Nextcloud using ldap user authentication and loglevel debug write user passwords to log file. Vulnerable versions: 26.0.4, 27.0.1.
Steps To Reproduce:
- Use a nextcloud with ldap user authentication.
- Set nextcloud config loglevel to 0 (debug).
- Login to nextcloud using a ldap user.
- Search for lines with 'ldap_bind' in nextcloud log file.
Supporting Material/References:
Sample log file:
{"reqId":"QRqbkhMpRAY1ugvQMrPk","level":0,"time":"2023-08-08T11:17:11-03:00","remoteAddr":"<IPADDRESS>","user":"--","app":"user_ldap","method":"POST","url":"/login","message":"Calling LDAP function ldap_bind with parameters [{},\"uid=<USERNAME>\",\"<PASSWORD>\"]","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36","version":"27.0.1.2","data":{"app":"user_ldap"}}
Affected file:
apps/user_ldap/lib/LDAP.php
Vulnerable code:
private function preFunctionCall(string $functionName, array $args): void {
$this->curArgs = $args;
$this->logger->debug('Calling LDAP function {func} with parameters {args}', [
'app' => 'user_ldap',
'func' => $functionName,
'args' => json_encode($args),
]);
Impact
Local administrator can retriave user passwords.
What the report shows
The target is Nextcloud server, specifically the user_ldap app used for LDAP-backed user authentication. The researcher found that when the instance runs at debug log level, the LDAP bind call is logged together with its arguments, and those arguments include the user's password in cleartext. The report lists versions 26.0.4 and 27.0.1 as vulnerable and points to the affected file apps/user_ldap/lib/LDAP.php.
The reproduction is short and needs only an instance with LDAP authentication and debug logging enabled:
- Use a Nextcloud with LDAP user authentication.
- Set the Nextcloud config loglevel to 0 (debug).
- Log in to Nextcloud using an LDAP user.
- Search for lines containing
ldap_bindin the Nextcloud log file.
The supporting material is a sample log line showing what step 4 returns:
{"reqId":"QRqbkhMpRAY1ugvQMrPk","level":0,"time":"2023-08-08T11:17:11-03:00","remoteAddr":"<IPADDRESS>","user":"--","app":"user_ldap","method":"POST","url":"/login","message":"Calling LDAP function ldap_bind with parameters [{},\"uid=<USERNAME>\",\"<PASSWORD>\"]","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36","version":"[redacted]","data":{"app":"user_ldap"}}
The entry records the request to /login, the user_ldap app, and a message that embeds the bind parameters: an empty options array, the bind DN built from the username, and the password. The password therefore lands in the log file as plain text.
The report was rated medium severity with a CVSS score of 4.6, under the weakness Cleartext Storage of Sensitive Information. No bounty amount is recorded. A security advisory was published at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-35p6-4992-w5fr, and the report was disclosed on 21 November 2023.
Root cause
The vulnerable code is a wrapper that logs every LDAP function call before executing it:
private function preFunctionCall(string $functionName, array $args): void {
$this->curArgs = $args;
$this->logger->debug('Calling LDAP function {func} with parameters {args}', [
'app' => 'user_ldap',
'func' => $functionName,
'args' => json_encode($args),
]);
The method serialises the full argument array with json_encode and writes it at debug level. For ldap_bind, one of those arguments is the password, so the generic "log all arguments" approach captures a credential. The method logs the full argument array, so for ldap_bind the password is captured. Because the entry is only emitted at debug level, the exposure depends on the instance being configured with loglevel 0.
Impact
The report's impact statement is that a local administrator can retrieve user passwords. Anyone able to read the log file, which in practice means someone with administrative or filesystem access to the server, can recover the cleartext passwords of users who have logged in while debug logging was active. The report does not describe any path for a remote or unauthenticated attacker, and it does not claim that the log is exposed over the network.
How this kind of bug works
Sensitive data in logs is a class of its own: the application behaves correctly, but its diagnostic output copies secrets into a place with different access controls and a longer lifetime than the secret itself. Logging frameworks make this easy to do accidentally. A wrapper that logs "function name plus arguments" is convenient and uniform, and it is exactly the pattern that catches credentials, session identifiers, tokens and personal data whenever one of the wrapped calls takes them as a parameter.
The bug class appears in several shapes: request bodies logged by a debug middleware, SQL statements logged with bound values, authentication libraries logging the bind or the token exchange, and error handlers that dump the whole object on failure. Debug levels make it worse because they are often switched on temporarily during incident response and then left on, and because the resulting files are frequently shipped to support, copied to shared storage or included in backups.
The defences are layered. The first is to never log raw argument arrays for calls that can carry secrets, and to redact known sensitive keys before serialisation. The second is to keep debug logging off by default and to make the risk explicit in the configuration. The third is to treat log files as sensitive data: restrictive file permissions, short retention, and no inclusion in support bundles without review. Structured logging with an explicit allowlist of fields is more robust than dumping everything and hoping nobody notices.
How to test for it
Look for features that handle credentials and for code paths that log their inputs. Good starting points are authentication endpoints, password change and reset flows, integrations that bind to a directory or a third-party API, and any wrapper class that logs before or after calling an external library.
- Enable the most verbose logging the application offers, if you can do so in a test instance.
- Perform an action that submits a secret: log in, change a password, connect an integration, trigger a failed authentication.
- Read the log output and search for the secret value, for the parameter names around it, and for the function or endpoint that handled the request.
- Repeat with a distinctive marker value so that a match in the log is unambiguous.
A positive result is the exact secret you submitted appearing in a log entry, ideally with enough context to show which component wrote it. A near miss, such as the username or a hash appearing, is not the same finding. Common false positives are values that are masked in the rendered message but present in a structured field, secrets that only appear when an unusual error path is triggered, and log entries that are written to a channel the attacker cannot reach. Check who can actually read the log before claiming impact, and note whether the verbose level is the default or requires an administrative change.
How it is fixed
The report does not describe how the issue was fixed. Where the dump is kept, it should be restricted to non-sensitive parameters.
Hunting notes
This bug class hides in integration and authentication code: directory binds, OAuth and token exchanges, mail and SMS gateways, payment clients, and anything with a generic "call this library and log the call" wrapper. Recon signals include debug or trace logging options in configuration files, log viewer features in the admin interface, support bundle endpoints, and error pages that display stack traces with request data. Reading the source of the relevant module is usually faster than black-box probing, since the log statement itself shows what will be captured.
To make the report land, show the exact log line with the secret, state which configuration is required, and describe who can read the log in a realistic deployment. If the secret is only written when an administrator enables debug mode, say so plainly rather than overstating the exposure; programs tend to accept these reports when the data is a real credential and the access path is concrete, and to close them when the only reader is the person who already controls the server.
What happened, in plain words
Nextcloud is a self-hosted file sharing and collaboration platform: an organisation installs it on its own server and its staff use it through a browser to store files, calendars and contacts. Instead of keeping its own list of usernames and passwords, Nextcloud can be told to ask a central directory service, LDAP, to check them. LDAP is a long-standing protocol for storing and looking up user accounts in one place; many companies run one so that a single username and password works across all their internal systems. When Nextcloud checks a password against LDAP, it performs a "bind": it sends the username and password to the directory and the directory answers whether they are correct.
Nextcloud also keeps a log file: a running diary of what the software did, written for troubleshooting. The diary can be set to different levels of detail. At the normal level it records important events; at "debug" level (loglevel 0 in the configuration) it records almost everything, including the internal calls the software makes.
The researcher found that at debug level, the LDAP bind call is written to the log together with all of its inputs, and one of those inputs is the user's password, in plain readable text. The report names versions 26.0.4 and 27.0.1 as vulnerable and points to the file apps/user_ldap/lib/LDAP.php.
Reproducing it
The steps are short and need only a test instance that uses LDAP login and has debug logging switched on:
- Use a Nextcloud with LDAP user authentication.
- Set the Nextcloud config loglevel to 0 (debug).
- Log in to Nextcloud using an LDAP user.
- Search for lines containing
ldap_bindin the Nextcloud log file.
Each step matters. Step 1 makes sure the LDAP code path is actually used, because the bug lives in that integration. Step 2 sets the log level to debug, which is when the call is recorded. Step 3 gives the software a real password to send to the directory. Step 4 is the check: if the password shows up in the log, the bug is confirmed.
The sample log line the researcher supplied shows what step 4 returns:
{"reqId":"QRqbkhMpRAY1ugvQMrPk","level":0,"time":"2023-08-08T11:17:11-03:00","remoteAddr":"<IPADDRESS>","user":"--","app":"user_ldap","method":"POST","url":"/login","message":"Calling LDAP function ldap_bind with parameters [{},\"uid=<USERNAME>\",\"<PASSWORD>\"]","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36","version":"[redacted]","data":{"app":"user_ldap"}}
Read field by field, the entry says:
reqId: an identifier for this one request, so support staff can follow it through the log.level: 0, meaning debug, the most verbose setting.time: when it happened.remoteAddr: the address the request came from.user:--.app:user_ldap, the component that handles directory logins.methodandurl: aPOSTto/login, the form submission that carries the credentials.message: the important part. It records the call toldap_bindwith its parameters: an empty options array{}, the directory name built from the username (uid=<USERNAME>), and the password itself.userAgent: the browser that made the request.version: the Nextcloud build,[redacted].
The password is therefore sitting in the log file as ordinary text.
Why it happens
The vulnerable code is a small helper that writes a log entry before every call to the directory library:
private function preFunctionCall(string $functionName, array $args): void {
$this->curArgs = $args;
$this->logger->debug('Calling LDAP function {func} with parameters {args}', [
'app' => 'user_ldap',
'func' => $functionName,
'args' => json_encode($args),
]);
It takes the function name and the full list of arguments, converts the arguments to text with json_encode, and writes them at debug level. That is convenient for troubleshooting, but it treats every argument as safe to record. For ldap_bind, one argument is the password, so a generic "log everything" habit captures a credential. The exposure only happens when the instance is configured with loglevel 0.
Impact
The report states that a local administrator can retrieve user passwords. In practice, anyone who can read the log file, meaning someone with administrative or file system access to the server, can recover the plain passwords of users who logged in while debug logging was on. The report describes no route for a remote or unauthenticated attacker and does not claim the log is reachable over the network.
The report was rated medium severity with a CVSS score of 4.6, under the weakness Cleartext Storage of Sensitive Information. No bounty amount is recorded. A security advisory was published at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-35p6-4992-w5fr, and the report was disclosed on 21 November 2023.
In general, secrets in log files
This is a bug class of its own: the application does its job correctly, but its diagnostic output copies secrets into a place with different access rules and a longer life than the secret itself. Think of a receptionist who keeps a notebook of every visitor; useful for security, but if the notebook also records the door codes people type in, it becomes a liability.
Logging frameworks make the mistake easy. A wrapper that records "function name plus arguments" is tidy and uniform, and it is exactly the pattern that catches passwords, session identifiers, tokens and personal data whenever a wrapped call takes them as a parameter. The same shape appears as request bodies logged by debug middleware, database queries logged with their values, authentication libraries logging a bind or a token exchange, and error handlers that dump whole objects when something fails. Debug levels make it worse because they are often switched on during an incident and then left on, and because log files get shipped to support, copied to shared storage or swept into backups.
Defences come in layers. Never log raw argument lists for calls that can carry secrets, and blank out known sensitive fields before writing. Keep debug logging off by default and make the risk clear in the configuration. Treat log files as sensitive data: tight file permissions, short retention, and no inclusion in support bundles without review. Structured logging with an explicit list of allowed fields is sturdier than dumping everything and hoping nobody looks.
Testing for it
Look for features that handle credentials and for code that logs their inputs: login pages, password change and reset flows, integrations that connect to a directory or an outside service, and any wrapper that logs before or after calling a library.
- Turn on the most verbose logging the application offers, in a test instance.
- Do something that submits a secret: log in, change a password, connect an integration, or trigger a failed login.
- Read the log and search for the secret, for the parameter names around it, and for the function or page that handled the request.
- Repeat with a distinctive marker value so a match in the log is unambiguous.
A positive result is the exact secret you submitted appearing in a log entry, ideally with enough context to show which component wrote it. A near miss, such as the username or a hash, is not the same finding. Common false positives are values masked in the displayed message but present in a structured field, secrets that appear only on an unusual error path, and entries written to a log the attacker cannot reach. Check who can actually read the log before claiming impact, and note whether the verbose level is the default or needs an administrator to change it.
How it is fixed
The report does not describe how the issue was fixed. Where a dump is kept, it should cover only harmless parameters.
Where to hunt
This bug class hides in integration and authentication code: directory binds, token exchanges, mail and SMS gateways, payment clients, and anything with a generic "call this library and log the call" wrapper. Signals to look for include debug or trace options in configuration files, log viewers in the admin interface, support bundle features, and error pages that show stack traces with request data. Reading the source of the relevant module is usually faster than probing blindly, because the log statement itself shows what will be captured.
To make a report land, show the exact log line with the secret, state which configuration is required, and describe who can read the log in a realistic deployment. If the secret is only written when an administrator enables debug mode, say so plainly rather than overstating the exposure; programs tend to accept reports where the data is a real credential and the access path is concrete, and to close them where the only reader is the person who already controls the server.
Glossary
- Nextcloud: self-hosted software for file sharing and collaboration, installed on an organisation's own server.
- LDAP: a protocol for storing and looking up user accounts centrally, so one username and password works across many systems.
- Bind: the LDAP operation that sends a username and password to the directory to check them.
- Log file: a diary the software writes about what it did, used for troubleshooting.
- Debug level (loglevel 0): the most verbose logging setting, recording internal detail that normal levels omit.
- Cleartext: data stored or sent in readable form, with no encryption or masking.
- Credential: a secret used to prove identity, such as a password or token.
- Request: a message a browser sends to a server asking it to do something, such as submitting a login form.
POST: the request method used to send data, here the login form./login: the address on the server that handles login submissions.user_ldap: the Nextcloud component that handles directory logins.json_encode: a function that converts data into JSON text, the format used in the log line.- Wrapper: code that sits around a library and runs extra steps, such as logging, before or after each call.
- CVSS: a standard scoring system for the severity of a security flaw; 4.6 is in the medium range.
- Security advisory: a public notice describing a flaw and its fix.
- Redaction: removing or masking secrets before data is stored or shared.
- Retention: how long data such as logs is kept before deletion.
- False positive: a test result that looks like a finding but is not one.