Debug mode: Marks UMB-DEBUG cookie as HttpOnly and Secure#21032
Debug mode: Marks UMB-DEBUG cookie as HttpOnly and Secure#21032AndyButland merged 6 commits intomainfrom
Conversation
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
… warns the user if that is not the case
There was a problem hiding this comment.
Pull request overview
This PR addresses a security vulnerability by improving the security configuration of the UMB-DEBUG cookie used for performance profiling. The changes ensure the cookie follows security best practices (HttpOnly, Secure based on settings, SameSite=Strict, session-only) and refactors the implementation to use ICookieManager for better encapsulation. The frontend is enhanced with proper verification that cookie operations succeed and provides user feedback when they fail due to cross-site restrictions.
Key Changes:
- Improved cookie security settings (HttpOnly, dynamic Secure flag, SameSite=Strict, session cookie)
- Refactored backend to use
ICookieManagerabstraction instead of direct cookie manipulation - Enhanced frontend with status verification and user-friendly error notifications
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Umbraco.Web.Common/Repositories/WebProfilerRepository.cs |
Refactored to use ICookieManager with secure cookie settings (HttpOnly, dynamic Secure, SameSite=Strict) and removed persistent expiration |
src/Umbraco.Web.UI.Client/src/packages/performance-profiling/dashboard-performance-profiling.element.ts |
Added verification of profiler status changes, loading states, error notifications, and replaced unsafeHTML with umb-localize components |
src/Umbraco.Web.UI.Client/src/assets/lang/en.ts |
Added new error message localization strings and updated description to mention same-site limitation |
Co-authored-by: Copilot <[email protected]>
AndyButland
left a comment
There was a problem hiding this comment.
Looks good @iOvergaard and all works as expected. Toggle status is retained, the cookie is set with the appropriate settings and it works to enabled debug mode when browsing the front-end of the website.
I'll cherry-pick this back for 16.5 too.
* fix: sets profiling cookie to httpOnly and strict in order to run non-secure * fix: adds extra message to explain when you can set a cookie * fix: simplify cookie explanation comment in WebProfilerRepository 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: checks that the profiler is actually enabled and/or disabled and warns the user if that is not the case * Update src/Umbraco.Web.UI.Client/src/assets/lang/en.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Copilot <[email protected]>
|
@iOvergaard - I've cherry-picked this over for 16.5 in the commit you can see linked above. I just had to rework how the context was consumed on the client. I think it's all good and have tested it out, but if you want to take a look please do. |
|
All good, @AndyButland ! |
Summary
This PR addresses a security scanning alert about the debug profiling cookie and improves the overall cookie handling:
UMB-DEBUGcookie now respects theUseHttpssetting instead of hardcodingSecure=falseFixes https://github.com/umbraco/Umbraco-CMS/security/code-scanning/1730
Changes
Backend:
HttpContext.Response.Cookiesusage withICookieManagersecure: _globalSettings.UseHttpsinstead ofsecure: falsehttpOnly: trueandsameSiteMode: "Strict"Frontend:
unsafeHTMLwithumb-localizecomponentsNote on SameSite=Strict
Because the cookie uses
SameSite=Strict, it only works when the BackOffice and front-end share the same domain. For cross-site setups (e.g., headless), users can use?umbDebug=truequery string orX-UMB-DEBUGheader instead.Test steps
Cross-site scenario (should show warning)
npm run devin the client folder)Same-site scenario (should work)
🤖 Generated with Claude Code