Health Checks: Add check for imaging HMAC secret key#21991
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Security health check to the Umbraco CMS core that warns administrators when Umbraco:CMS:Imaging:HMACSecretKey is not configured, helping surface the risk of unsigned image manipulation URLs.
Changes:
- Introduces
ImagingHMACSecretKeyCheckto report Warning when the HMAC key is missing and Success when configured. - Adds a documentation link constant for the check under
Constants.HealthChecks.DocumentationLinks.Security. - Adds localization keys (en / en-us) and unit tests covering warning/success and the non-executable action behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Umbraco.Core/HealthChecks/Checks/Security/ImagingHMACSecretKeyCheck.cs |
Implements the new security health check logic and documentation link behavior. |
src/Umbraco.Core/Constants-HealthChecks.cs |
Adds a documentation URL constant for the new health check. |
src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml |
Adds localized success/warning messages for the new check (en-us). |
src/Umbraco.Core/EmbeddedResources/Lang/en.xml |
Adds localized success/warning messages for the new check (en). |
tests/Umbraco.Tests.UnitTests/Umbraco.Core/HealthChecks/ImagingHMACSecretKeyCheckTests.cs |
Adds unit tests for warning, success, and ExecuteAction throwing. |
src/Umbraco.Core/HealthChecks/Checks/Security/ImagingHMACSecretKeyCheck.cs
Outdated
Show resolved
Hide resolved
…//github.com/umbraco/Umbraco-CMS into v17/feature/healthcheck-for-imaging-settings
There was a problem hiding this comment.
Looks good, tests good.
I'll go ahead and approve since everything works, and this is really just a thought.
But in #21976 you create a HmacSecretKeyService which has the method HasHmacSecretKey. Wouldn't it be better to use that rather than duplicate the logic here? Additionally, it begs the question: Shouldn't the same service be used to retrieve the HmacSecretKey as well? Anyways, that's a smaller architectural detail, so I'll still approve this PR, but I won't merge for now so you have a chance to see what you think 😄
|
Docs PR is here: umbraco/UmbracoDocs#7864 |
|
It's a good point. I'll update to use the service in the health check. Currently the |
Prerequisites
Description
Adds a new Security group health check that warns administrators when
Umbraco:CMS:Imaging:HMACSecretKeyis not configured.Without an HMAC key, any caller can craft arbitrary image resize/crop URLs. The health check surfaces this as a Warning (not an Error — the site functions without it, but it is a security risk) alongside a link to the imaging settings documentation.
Testing
Automated
Unit tests have been added in `ImagingHMACSecretKeyCheckTests.
Manual
Umbraco:CMS:Imaging:HMACSecretKeyset.Umbraco:CMS:Imaging:HMACSecretKeyinappsettings.jsonand restart.You can generate a sample HMAC secret key from Powershell with: