Review main Merged

78754[TASK] Allow nonce values explicitly in PageRenderer inline methods

Oliver Hader CR +2 V +2 Normal +96 −51 updated 06/03/23, 08:25

Commit message

Allow to use nonce explicitly for `PageRenderer` methods
`addJsInlineCode()`, `addJsFooterInlineCode()` and
`addCssInlineBlock()`.

The backend login styles are already using those nonce values.
As a consequence, the variable values `loginBackgroundImage`
and `loginHighlightColor` have to be sanitized by the new
`GeneralUtility::sanitizeCssVariableValue()` function.

Review

  • Code review CR +2 Done
    • Oliver Hader +2
    • Alexander Stehlik +1
    • Daniel Haupt +1
  • Verified V +2 Done
    • Oliver Hader +2
    • Daniel Haupt +1
    • core-ci +1 CI

Issues 1

Files 8

Review log 2633

Show 58 earlier messages
  1. Oliver Hader uploaded patch set 1 04/19/23, 14:38

  2. core-ci voted on patch set 1 V -1 04/19/23, 15:02 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40909

  3. Oliver Hader uploaded patch set 2 V -1 04/21/23, 22:48

  4. core-ci voted on patch set 2 V -1 04/21/23, 22:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41069

  5. Oliver Hader uploaded patch set 3 V -1 04/22/23, 09:25

  6. core-ci voted on patch set 3 V +1 04/22/23, 09:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41084

  7. Oliver Klee commented on patch set 3 04/22/23, 10:02

    GeneralUtilityTest.php:1913

    Please let's have (human-readable) keys/descriptions for the single items that describe the intention of the dataset, for example: ```php yield 'url in double quotes' => ['url("/my-background.png")', 'url("/my-background.png")']; ```
  8. Oliver Klee commented on patch set 3 04/22/23, 10:03

    GeneralUtility.php:3341

    We can inline `$value` here.
  1. Oliver Hader uploaded patch set 4 V +1 04/22/23, 11:02

  2. Oliver Hader commented on patch set 3 04/22/23, 11:02

    GeneralUtility.php:3341 Reply

    Done

    GeneralUtilityTest.php:1913 Reply

    Done
  3. core-ci voted on patch set 4 V +1 04/22/23, 11:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41088

  4. Andreas Kienast commented on patch set 4 04/24/23, 13:44

    Frontend\Http\RequestHandler->addCssToPageRenderer() calls PageRenderer->addCssInlineBlock() without nonce - on purpose?
  5. Oliver Klee wrote 04/24/23, 13:45

    Removed cc Oliver Klee.
  6. Oliver Hader commented on patch set 4 04/24/23, 16:23

    Reply

    That's a different story - those are inline assets - each single one should be enabled explicitly to `useNonce`, which is not possible, since it just renders a big blob of string text. I'm reluctant to enable a nonce value per default - getting rid of inline assets basically is the goal, since it might contain XSS (more focussed on scripts than styles).
  7. Benni Mack updated the commit message in patch set 5 V +1 05/03/23, 09:47

  8. Oliver Hader rebased onto patch set 6 05/03/23, 12:40

  9. core-ci voted on patch set 6 V +1 05/03/23, 13:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41533

  10. Alexander Stehlik commented on patch set 6 05/11/23, 08:40

    PageRenderer.php:2151

    Does it make sense to resolve this TODO as well with this change? Currently using inlineLanguageLabelFiles causes a CSP violation.
  11. Oliver Hader commented on patch set 6 05/11/23, 09:32

    PageRenderer.php:2151 Reply

    In which context does it cause a CSP violation?
  12. Alexander Stehlik commented on patch set 6 05/11/23, 09:39

    PageRenderer.php:2151 Reply

    I enabled the feature flag ecurity.frontend.enforceContentSecurityPolicy and use the TypoScript setting inlineLanguageLabelFiles (https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#inlinelanguagelabelfiles) The script tag is rendered without nonce in the HTML which causes a CSP violation. In my tests this change resolved the issue: https://gist.github.com/astehlik/8105e17bd237448003f344345b0b398d
  13. Oliver Hader uploaded patch set 7 V +1 05/11/23, 09:52

  14. Oliver Hader commented on patch set 7 05/11/23, 09:53

    PageRenderer.php:2151 Reply

    Good catch! Thanks! I've updated this change using your Gist patch.
  15. Oliver Hader commented on patch set 7 05/11/23, 09:55

    PageRenderer.php:2151 Reply

    The `inlineJavascriptWrap` aspect was addressed in #100614 (deprecating the class property in favor of using the new method `wrapInlineScript`).
  16. core-ci voted on patch set 7 V +1 05/11/23, 10:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41755

  17. Alexander Stehlik voted on patch set 7 CR +1 05/11/23, 10:03

  18. Daniel Haupt commented on patch set 7 05/13/23, 09:30

    nit: to be sanitized
  19. Oliver Klee updated the commit message in patch set 8 CR +1 V +1 05/13/23, 13:17

  20. Oliver Klee commented on patch set 8 05/13/23, 13:17

    Reply

    Done
  21. Daniel Haupt voted on patch set 8 V +1 CR +1 05/13/23, 13:20

  22. Alexander Stehlik voted on patch set 8 CR +1 05/13/23, 13:21

  23. core-ci voted on patch set 8 V +1 05/13/23, 13:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41797

  24. Oliver Hader voted on patch set 8 V +2 CR +2 06/03/23, 08:24

  25. Oliver Hader merged patch set 9 06/03/23, 08:25