Repository navigation
fix(logging): keep credentials out of log calls - #2076
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
An active moderate finding shows the logging hygiene guard misses method-derived email and message-body data, so sensitive values can still be logged without the test failing.
1 open issue
What changed in this PR
This pull request hardens application logging by removing credentials, tokens, personal data, and payment payloads from log messages, standardizing calls around literal format strings, and adding a tokenizer-based hygiene regression test.
Changes:
- Replaces sensitive log values with safer identifiers, statuses, or aggregate counts.
- Converts interpolated and concatenated log messages to fixed format strings.
- Adds coverage for detecting non-literal formats and selected sensitive log arguments.
| File | Description |
|---|---|
| WebServices/AuthenticationWebService.php | Removes session tokens from authentication and sign-out logs. |
| tests/lib/Common/Logging/LogCallHygieneTest.php | Adds tokenizer-based checks for unsafe log formats and sensitive arguments. |
| Presenters/Reservation/ReservationEmailPresenter.php | Removes recipient email addresses from reservation logs. |
| Presenters/Reservation/GuestReservationPresenter.php | Removes guest email logging from reservation creation logs. |
| Presenters/Integrate/SlackPresenter.php | Removes the submitted Slack token from logs. |
| Presenters/Install/ConfigurePresenter.php | Replaces configuration editor email logging with a user ID. |
| Presenters/GuestParticipationPresenter.php | Removes participant email logging from invitation messages. |
| Presenters/ForgotPwdPresenter.php | Removes password-reset email details from logs. |
| Presenters/Admin/ManageThemePresenter.php | Converts uploaded-file log messages to fixed formats. |
| Presenters/Admin/ManageResourcesPresenter.php | Converts resource image path logging to a fixed format. |
| Presenters/Admin/ManageConfigurationPresenter.php | Replaces configuration editor email logging and fixes dynamic log formats. |
| plugins/Authentication/Saml/adSAML.php | Converts a concatenated SAML error message to a literal format. |
| plugins/Authentication/Ldap/Ldap2Wrapper.php | Converts LDAP error messages to fixed format strings. |
| plugins/Authentication/CAS/CAS.php | Replaces the CAS logout email with a user ID. |
| plugins/Authentication/ActiveDirectory/AdLdapWrapper.php | Converts Active Directory exception logging to a fixed format. |
| Pages/Page.php | Removes submitted and expected CSRF token values from logs. |
| Pages/Ajax/AutoCompletePage.php | Converts autocomplete log messages to fixed formats. |
| lib/WebService/WebServiceSecurity.php | Removes web-service session tokens from request logs. |
| lib/Email/EmailService.php | Replaces logged email addresses with safer delivery information. |
| lib/Database/MySQL/MySqlConnection.php | Converts SQL log construction to fixed format arguments. |
| lib/Common/Validators/URI/URIScriptValidator.php | Converts URI redirect logging to a fixed format. |
| lib/Common/Validators/URI/ParamsValidator.php | Converts parameter-validation logging to fixed formats. |
| lib/Application/Schedule/CalendarSubscriptionValidator.php | Removes calendar subscription keys from logs. |
| lib/Application/Reservation/Notification/OwnerEmailNotification.php | Replaces owner email logging with a user ID. |
| lib/Application/Authentication/WebServiceAuthentication.php | Removes web-service session token logging. |
| lib/Application/Authentication/PostRegistration.php | Replaces registration email logging with user identifiers. |
| lib/Application/Authentication/GuestUserService.php | Removes guest email logging from account-creation messages. |
| lib/Application/Authentication/CaptchaService.php | Removes submitted and expected CAPTCHA values from logs. |
| lib/Application/Admin/UserImportCsv.php | Stops logging imported row contents, including plaintext passwords. |
| Domain/Values/UserPreferences.php | Converts preference-name logging to fixed formats. |
| Domain/ScheduleLayout.php | Consolidates period logging using a fixed format. |
| Domain/PaymentGateway.php | Replaces PayPal and Stripe payload logging with IDs and statuses. |
| Domain/Access/ReservationRepository.php | Converts reservation repository messages to fixed format strings. |
Review effort: Lite
4488014 to
bdc5a38
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The change spans authentication, imports, URI validation, SQL, and PayPal/Stripe flows, while key redacted outputs and third-party exception behavior cannot be runtime-verified automatically, so representative log flows require human validation.
No open issues 🎉
1 resolved since last review
Review effort: Lite
02c92fd to
0529127
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Subscription credentials, API session tokens, and payment payloads remain exposed through request metadata and SQL logging, while regression guards miss known sensitive-data bypasses.
7 open issues
Prevent SQL logs from exposing session and payment secrets · New Redact subscription credentials from shared URL and referrer logs · New Log safe PayPal failure diagnostics when responses lack id or status · New Include missing-field reasons in CSV import errors · New Add log-output regression tests for sensitive values · New Detect case-insensitive and nullsafe credential member reads · New Resolve qualified and reordered json_encode arguments · New
Review effort: Max (adaptive)
|
@lucs7 I'm fine with hiding credentials. I'm a bit less sure about hiding email addresses. What is the benefit of that? As only the system administrator can access the log files. |
Remove values that must not reach the logs: - CSRF tokens (logged at error level by default), API session tokens, the Slack token, calendar subscription keys and the expected captcha answer - PayPal and Stripe request and response bodies, replaced by the order, charge or refund id and status; for PayPal also the HTTP status and PayPal's error name and debug id, so a rejected request can still be diagnosed - the values of a skipped user import row, which include the plaintext password; the row number and the missing field are logged instead - the query string of the request URL and referrer, which can carry the calendar subscription key or an activation code Usernames and email addresses are not treated as secrets: administrators can see them for every account anyway. Extend the Log:: call test to reject arguments named like a token, password, secret or key, in any case and through ?->, and JSON-encoded payment payloads, also as \json_encode() or with named arguments. Assisted-by: Claude:claude-opus-5-5 Assisted-by: Claude:claude-fable-5-2
Agreed, I've dropped the email changes. The PR now only removes credentials: CSRF and session tokens, the Slack token, calendar subscription keys, the captcha answer, payment payloads and the user-import row with its plaintext password. Usernames and email addresses stay in the log as before. |
0529127 to
1657cbc
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings leave request query credentials exposed in logs and the hygiene guard unable to detect several common secret names.
2 open issues
7 resolved since last review
Redact subscription credentials from shared URL and referrer logs Prevent SQL logs from exposing session and payment secrets Resolve qualified and reordered json_encode arguments Detect case-insensitive and nullsafe credential member reads Add log-output regression tests for sensitive values Include missing-field reasons in CSV import errors Log safe PayPal failure diagnostics when responses lack id or status
Review effort: Lite
| $userId = $server->GetHeader(WebServiceHeaders::USER_ID); | ||
|
|
||
| Log::Debug('Handling secure request. url=%s, userId=%s, sessionToken=%s', $_SERVER['REQUEST_URI'], $userId, $sessionToken); | ||
| Log::Debug('Handling secure request. url=%s, userId=%s', $_SERVER['REQUEST_URI'], $userId); |
| private const SECRET_VARIABLES = '/^\$(token|sessionToken|csrfToken|password|newPassword|currentPassword|secret|apiKey|providedKey)$/i'; | ||
| /** Properties or methods whose value must never be logged, matched case-insensitively. */ | ||
| private const SECRET_MEMBERS = ['sessiontoken', 'csrftoken', 'password']; |
JohnVillalovos
left a comment
There was a problem hiding this comment.
LGTM. It may not be perfect but a good improvement
Thanks @lucs7


Description
Several
Log::calls write credentials or payer data toapp.log, some atthe default
errorlevel. This PR removes them and adds a test that keepsthem out.
What counts as a secret
Credentials must never reach the log: passwords, CSRF and session tokens,
API and subscription keys, captcha answers and payment payloads. Usernames
and email addresses are not treated as secrets. An administrator can already
see them for every account, so logging them exposes nothing new.
Removed from log messages
expected token at
error. It now logs whether the token was missing ormismatched, plus the user id.
subscription keys and the expected captcha answer.
password. Only the row number is logged now; the reason is already logged
by
UserImportCsvRow.order, charge or refund id and its status.
User ids instead of email addresses
Where a message identified a user by email address, it now uses the user id.
That keeps messages consistent; it is not a secrecy measure. Messages with no
user id available (guest reservations, password reset requests, outgoing
email) no longer name the address.
Guard test
LogCallHygieneTestalready checks that everyLog::call uses a literalformat string. This PR adds
testLogCallsPassNoSecrets, which fails when anargument is named like a token, password, secret or key, or serializes a
payment payload with
json_encode. It also rejects arguments named like anemail address, to keep the user-id convention above.
The check goes by variable and member names, so it catches the common
mistakes rather than every possible leak.
No behaviour changes apart from the log contents.