Skip to content

Disable the debug toolbar and the /_profiler/phpinfo page in dev - #298

Open
robertSt7 wants to merge 4 commits into
2026.3from
fix/disable-profiler-toolbar-phpinfo
Open

robertSt7 wants to merge 4 commits into
2026.3from
fix/disable-profiler-toolbar-phpinfo

Conversation

@robertSt7

@robertSt7 robertSt7 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Resolves pimcore/service-operations#935

Problem

In the dev environment the Symfony profiler exposes /_profiler/phpinfo. It prints phpinfo() - including environment variables and, depending on the setup, secrets - to anyone who can reach the instance. Dev and staging instances are often reachable from the network. The page is served as soon as the profiler is enabled; it ignores web_profiler.toolbar, so simply turning the toolbar off does not close it.

Root cause

ProfilerController::phpinfoAction() (symfony/web-profiler-bundle 7.4) only checks that the profiler service exists. Core's routing_dev.yaml imports the profiler routes, and the skeleton did not configure anything for them.

Fix

  • config/packages/dev/config.yaml: web_profiler.toolbar: false - toolbar off by default in dev (Dev Steering decision).
  • config/routes/dev/routes.yaml: redefine the _profiler_phpinfo route under the same name with condition: "false". The redefinition replaces the original route, so /_profiler/phpinfo falls through to the profiler's /{token} route, which only reports an unknown token. The rest of the profiler keeps working and path('_profiler_phpinfo') links still generate. Remove the route to get the page back.
  • README.md: new section "Symfony profiler (dev environment)" explaining the new defaults and how to activate the toolbar and the /_profiler/phpinfo page again (including the cache clear that is needed for the change to show up).
  • tests/Functional/Dev/ProfilerTest.php: boots the dev kernel and checks the route match, the response of /_profiler/phpinfo, that other profiler routes still match/generate, and that the toolbar is disabled.

Core is untouched. Same change for the demo app: pimcore/demo-enterprise (pimcore/demo-enterprise#551).

Testing

  • New test: 4 tests / 9 assertions pass with the change; 3 of 4 fail on the original config (phpinfo output served, _profiler_phpinfo matched, toolbar enabled). Run with PHPUnit against a Pimcore 2026.3 dev instance (the demo app, which uses the same dev config); not run by this repo's CI, which only does the create-project / install smoke test.
  • Walkthrough on a running dev instance with the patched files: /_profiler/phpinfo no longer returns the phpinfo page (before: 200 with the full page), the toolbar markers disappear from HTML pages, /_profiler/ still redirects to the search results.
  • The activation steps from the README were verified on a running dev instance: with toolbar: true the toolbar appears, with the _profiler_phpinfo route removed the phpinfo page is served again - both only after a cache clear.
  • YAML lint on all changed config files; php-cs-fixer (skeleton rules) clean on the new test.

Notes

  • Only affects the dev environment of newly created projects; prod/test and existing projects are untouched.
  • Not covered (only recorded): other profiler pages (request/config panels) remain reachable while the profiler is enabled in dev. Running with APP_ENV=prod / APP_DEBUG=0 stays the recommendation for anything reachable from the network.
  • BC: no PHP API, service id or config key of the framework changes; dev-only application config.

…environment

The profiler route /_profiler/phpinfo prints phpinfo() (environment variables, secrets) to anyone who
can reach a dev instance, and it stays reachable when the toolbar is switched off. Turn the toolbar off
by default and replace the phpinfo route with one that never matches, so the URL falls through to the
profiler token route. The rest of the profiler keeps working.

Adds a functional test that boots the dev kernel and checks the route, the response and the toolbar mode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new tests boot the dev kernel without the test database override, breaking database isolation.

1 open finding
What changed in this PR

Hardens the skeleton’s dev defaults by disabling the debug toolbar and blocking the profiler’s phpinfo page while preserving other profiler routes.

Changes:

  • Disables the dev toolbar by default.
  • Overrides the phpinfo route so it never matches.
  • Adds functional checks for the profiler defaults.
File Description
tests/​Functional/​Dev/​ProfilerTest.php Tests phpinfo blocking, profiler routes, and toolbar configuration.
config/​routes/​dev/​routes.yaml Prevents the phpinfo route from matching.
config/​packages/​dev/​config.yaml Disables the debug toolbar.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/Functional/Dev/ProfilerTest.php
Booting the dev environment skips the database override of the test environment, so the kernel would
use the development database instead of the one the test runner provides. Point DATABASE_URL at
PIMCORE_TEST_DB_DSN while the test runs and restore the environment afterwards.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Test cleanup can delete or overwrite existing database environment values, affecting subsequent tests.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread tests/Functional/Dev/ProfilerTest.php Outdated
…r test

Remember the original value and key presence of $_SERVER, $_ENV and the process environment
individually, so teardown puts every store back exactly as it was instead of copying one value to all.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The security-sensitive route override still needs validation against the skeleton’s installed dependencies.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@jdreesen

Copy link
Copy Markdown
Contributor

Is it really necessary to change Symfony's default behavior here?

@robertSt7

robertSt7 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@jdreesen Fair question. The toolbar default follows the Dev Steering decision. The phpinfo route is separate: toolbar: false doesn't close /_profiler/phpinfo, and Symfony's profiler has no option to disable it, since it only checks that the profiler exists. So the only ways to close it are to disable the whole profiler or to override the route. I chose a single dev-only route override in app config, so the framework default stays untouched. Deleting the route restores the page. If you'd rather keep this PR to the toolbar default, I can drop the route. Then the exposure would need a decision in core, and the demo-enterprise change would be reverted to match.

@jdreesen

Copy link
Copy Markdown
Contributor

If that's such an issue, shouldn't it be fixed in Symfony instead?

… dev

Explain the new dev defaults (toolbar off, /_profiler/phpinfo blocked) and the steps to turn each of them
back on, including the cache clear that is needed for the change to take effect.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused configuration changes, documentation, and regression tests are consistent, and the previously reported database isolation issues are addressed.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants