---
title: "Monolog: redacting nested secrets in PHP logs | VulCode"
description: "A fix in Monolog, the PHP logging library: RedactingFormatter now hides passwords nested in arrays under sensitive keys, also inside the message text."
url: "https://vulcode.com/en/opensource/contributions/monolog"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

Seldaek/monolog

# Monolog

A PHP logging library that sends records to files, sockets, inboxes, databases and web services. Symfony and Laravel use it, among others.

[See the repository](https://github.com/Seldaek/monolog) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: PHP
- **GitHub stars**: 21,407
- **Merged changes**: 1
- **Project site**: [seldaek.github.io](https://seldaek.github.io/monolog/)

## What we changed

RedactingFormatter now also hides secrets nested inside array values under sensitive keys, including copies that already reached the message text.

### What this work shows

- Masking sensitive data in logs

- Depth-limited recursion

- Monolog processors and formatters

- Regression tests in PHPUnit

What was broken

### A password inside an array reached the log

RedactingFormatter only collected strings to hide. When the value under password was an array, PsrLogMessageProcessor put it into the message as JSON, and the password stayed there in plain text, even though the context key itself was masked.

How we fixed it

### Secrets collected at any depth

A new helper, collectSensitiveValue(), walks the value under a sensitive key and collects every string, within the same MAX_DEPTH limit. A new test checks that the password from the array does not appear in the formatter's output.

[#2067](https://github.com/Seldaek/monolog/pull/2067)

## Merged change

1 9 September 2026

- [01 #2067Merged 9 September 2026 Fix RedactingFormatter missing secrets nested inside array-valued sensitive keys](https://github.com/Seldaek/monolog/pull/2067)

## What it taught us

Redacting secrets in logs has to walk into nested data and catch copies that leaked through another channel. We can find such a leak in someone else's code and close it with a regression test.

[More about this technology: PHP](https://vulcode.com/en/technologies/php)

## Other projects we write code for

- [**Composer** PHP · 29,590 stars The dependency manager for PHP: it installs and updates a project's libraries from its composer.json.](https://vulcode.com/en/opensource/contributions/composer)

- [**PHPMailer** PHP · 22,347 stars The classic PHP library for sending email, used by WordPress and many other systems.](https://vulcode.com/en/opensource/contributions/phpmailer)

- [**Carbon** PHP · 16,583 stars A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.](https://vulcode.com/en/opensource/contributions/carbon)

- [**Whoops** PHP · 13,231 stars A PHP library that turns uncaught exceptions into a readable error page with the stack trace, known from Laravel.](https://vulcode.com/en/opensource/contributions/whoops)

- [**ramsey/uuid** PHP · 12,642 stars A PHP library for generating universally unique identifiers (UUIDs).](https://vulcode.com/en/opensource/contributions/ramsey-uuid)

- [**Doctrine Lexer** PHP · 11,141 stars A base for lexers used by recursive descent parsers in PHP, used by Doctrine ORM among others.](https://vulcode.com/en/opensource/contributions/doctrine-lexer)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
