Skip to content

Header/footer row Text Color isn't checked as a color, so a saved value can add arbitrary CSS #4708

Open

Description

@rodica-andronache

Description

The header and footer row Text Color settings (hfg_{header,footer}_layout_{row}_new_text_color) are cleaned with wp_filter_nohtml_kses. That only removes HTML tags, so the value is never checked as a color. Whatever text is left is printed on the front end as the row's --color value.

Because of this, a saved value can close the CSS rule and add any CSS to the page. HTML tags are removed, so this is CSS injection, not XSS. It still matters for users who can customize the theme but don't have unfiltered_html, such as site admins on multisite. An invalid value like notacolor is also printed as-is instead of falling back to the default text color.

The row Border Color setting in the same builder already uses neve_sanitize_colors() (header-footer-grid/Core/Builder/Abstract_Builder.php, around lines 450–468). Text Color, around line 530, doesn't.

Expected: Text Color goes through neve_sanitize_colors() like Border Color. Invalid values are rejected, and the CSS after the color is dropped.

Current: the value is saved and printed as typed, minus HTML tags.

Step-by-step reproduction instructions

  1. Activate Neve. Neve Pro isn't needed, because the footer uses the normal Customizer save.
  2. Go to Appearance → Customize → Footer → Footer Main.
  3. In the browser console, run:
    wp.customize('hfg_footer_layout_main_new_text_color').set('#222;}body{background:lime}/*')
  4. Click Publish.
  5. Open the front end and search the page source for .footer-main{.
    • Bug: .footer-main{ ... --color: #222;}body{background:lime}/* and the whole page turns lime.
    • Expected: the injected CSS is gone, and the page keeps its normal background.
  6. Repeat with hfg_header_layout_main_new_text_color (Header Main). You get the same result.
  7. Repeat with notacolor. It's printed as --color: notacolor instead of falling back to the default.
  8. To compare, do step 3 with hfg_footer_layout_main_border_color. The value is cut to #222, or falls back to the default.

Screenshots, screen recording, code snippet or Help Scout ticket

Front-end CSS after saving #222;}body{background:lime}/* on Footer Main Text Color:

.footer-main{ --rowbwidth:0px; --rowbcolor: #ff0000; --color: #222;}body{background:lime}/*; ... }

Registration in header-footer-grid/Core/Builder/Abstract_Builder.php:

// Border Color
'sanitize_callback' => 'neve_sanitize_colors',
// Text Color
'sanitize_callback' => 'wp_filter_nohtml_kses',

The same values can also be saved through the Header Configure / Footer Configure abilities (inc/abilities/builder_configure.php). There, text_color only goes through sanitize_text_field(). pirate-bot flagged this on Codeinwp/neve-pro-addon#3310.

Environment info

Neve 4.2.19 (current release, code checked). Reproduced on a live site with Neve Pro 3.2.16 active (build of Codeinwp/neve-pro-addon#3311).

Is the issue you are reporting a regression

No

Activity

  1. added
    bug
    on Nov 19, 2026
  2. added theissue type on Nov 19, 2026
  3. girishpanchal30 commented on Nov 20, 2026

    @girishpanchal30
    Contributor

    @rodica-andronache I have fixed it with PR #4710

  4. kushh23 commented on Nov 20, 2026

    @kushh23

    🧪 QA steps and test links

    The header and footer row Text Color settings are saved without checking that the value is a color. A saved value can end the row's CSS rule and add any CSS to the front end, for example to restyle the whole page. Invalid colors are printed as typed instead of falling back to the default.

    Requires: the browser console in the Customizer, since the color picker only sends valid colors.

    Link Build Bot check
    Reproduce the bug Neve 4.2.19 (released) ✅ Reproduced: the whole front page has a lime background
    Verify the fix PR #4710 build a86a3f4 ✅ Fixed: same stored value, the page keeps its normal white background

    In the links:

    • Steps 1 to 4 are already done, and the links open on the front page. The value is stored directly instead of through Publish, so the Verify link checks that a value saved before the update is no longer printed.
    • Tools → QA Logs shows debug.log.

    Reproduce on Neve 4.2.19:

    1. Appearance → Customize → Footer → Footer Main.
    2. In the browser console, set hfg_footer_layout_main_new_text_color with wp.customize('<setting>').set('<value>') to a color followed by a closing brace and a body rule with a lime background, ending with an open CSS comment.
    3. Click Publish.
    4. Open the front end.
    • Bug: the whole page turns lime, and the page source shows the injected rule after .footer-main{ ... --color:.
    • Fixed: the page keeps its normal background, and --color holds only a valid color or the default.
    Edge cases
    • Same steps with hfg_header_layout_main_new_text_color (Header Main): same result.
    • Text Color set to notacolor: falls back to the default text color instead of printing --color: notacolor.
    • A normal color picked with the color picker on Header and Footer rows: still saves and shows on the front end.
    • Row background color and overlay color: valid colors still print, invalid ones fall back.
    • Row Vertical Alignment (top, middle, bottom): still applies.

    Fix: #4710 (open)

  5. pirate-bot commented on Nov 20, 2026

    @pirate-bot
    Collaborator

    QA agent — 🟢 Passing checks · Header and footer row Text Color no longer lets a saved value inject CSS; invalid colors fall back to the default.

    We installed Neve with this fix and repeated the issue's steps in the Customizer: setting the Footer Main and Header Main Text Color to a value that closes the CSS rule, then publishing. The front end kept its normal white background and showed the default text color. On the current release, the same steps printed the injected CSS and 'notacolor' as typed. A script tried 9 values on all six header and footer rows: invalid ones were rejected and valid hex, rgba and CSS-variable colors still saved and showed. Colors picked with the color picker, values already saved before the update, the Header/Footer Configure abilities, row background and overlay colors, vertical alignment and the PR's unit tests all behaved correctly.

    Worth a human look

    1. Try the injection value as a multisite site admin without unfiltered_html, the role the issue says is most affected (this run used a single-site administrator).
    2. Note: named CSS colors such as 'red' are now rejected for row Text Color, the same as Border Color. Check that no existing sites rely on named colors there.
    Checks (8 passed)
    • ✅ Footer Main: setting hfg_footer_layout_main_new_text_color to '[PRO]White label feature #222;}body{background:lime}/*' in the Customizer console and clicking Publish does not inject CSS: the front-end source has no 'body{background:lime}' after '.footer-main{', and the page background is not lime.
    • ✅ Header Main: the same injection value set on hfg_header_layout_main_new_text_color and published from the Customizer does not inject CSS on the front end (no 'body{background:lime}' after '.header-main', background not lime).
    • ✅ Publishing an invalid Text Color such as 'notacolor' (and other invalid edge values, for header and footer rows) is rejected and the front end falls back to the default text color instead of printing '--color: notacolor'; valid hex/rgba/CSS-variable values still save and print.
    • ✅ A normal color chosen with the Text Color color picker on a Header row and a Footer row still saves on Publish and is shown as that row's --color on the front end.
    • ✅ An injection value already stored in the theme mod before the update (bypassing the Customizer sanitizer) is not printed on the front end; the row's --color falls back to the default.
    • ✅ The Header Configure / Footer Configure abilities reject an injection or invalid row text_color (not saved, warning returned) and still save a valid text_color.
    • ✅ Row background color and overlay color: valid stored colors still print on the front end and invalid/injection values fall back; Row Vertical Alignment top/middle/bottom still applies as --valign.
    • ✅ The PR-added PHPUnit test for row text colors (tests/test-neve-row-text-color.php) and the other PR-added tests pass.

    Full report, evidence and session trail

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

Metadata

Metadata

Labels

agent-skipbug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions