Repository navigation
xss audit - #746
xss audit#746
Conversation
🤖 AI PR ReviewRisk level: ReviewSummary What I checked (important files)
Positive notes
Potential regressions / behaviour changes (callouts)
Tests / QA recommended
Other small suggestions
Missing tests / documentation
Conclusion Suggested changelog entry
|
There was a problem hiding this comment.
🟡 Changes recommended
Unsafe attribute stripping creates a stored-XSS path, while incomplete protection of encoded brackets allows shortcode execution during later processing.
4 open issues
4 files not reviewed
assets/build/admin/package.js: Generated fileassets/build/frontend/calculated.field.js: Generated fileassets/build/frontend/media.field.js: Generated filecompatibility/jet-engine/assets/build/editor.js: Generated file
What changed in this PR
This PR hardens JetFormBuilder against cross-site scripting across form rendering, dynamic presets, HTML notifications, and admin interfaces.
Changes:
- Adds context-specific escaping, URL-scheme checks, and protections against executing visitor-controlled shortcodes or formula content.
- Sanitizes external data and HTML previews while preserving supported formatting.
- Adds security regression tests and updates built assets and cache versions.
| File | Description |
|---|---|
| tests/wpunit/ToolsSanitizeInvariantsTest.php | Documents input sanitization boundaries. |
| tests/wpunit/StatusQueryParamMarkupTest.php | Tests status-query markup filtering. |
| tests/wpunit/RestErrorMessageSanitizationTest.php | Guards against raw exception responses. |
| tests/wpunit/RepeaterPresetRenderTest.php | Tests safe repeater preset rendering. |
| tests/wpunit/RedirectUrlSchemeTest.php | Tests redirect scheme restrictions. |
| tests/wpunit/PresetShortcodeNeutralizationTest.php | Tests preset shortcode neutralization. |
| tests/wpunit/PresetRichPipelineShortcodeTest.php | Tests shortcode protection in rich-content processing. |
| tests/wpunit/PresetRichAttributeShortcodeTest.php | Tests preset protection in labels and descriptions. |
| tests/wpunit/PresetRenderMatrixTest.php | Checks presets across field types. |
| tests/wpunit/PresetAccessControlTest.php | Enables compatibility behavior for callback-order testing. |
| tests/wpunit/PaypalPayerDataSanitizationTest.php | Tests payer and shipping sanitization. |
| tests/wpunit/MacroAttributeInjectionTest.php | Tests removal of injected macro attributes. |
| tests/wpunit/InlineCssEscapingTest.php | Tests style-element breakout protection. |
| tests/wpunit/GeneratedOptionLabelShortcodeTest.php | Tests generated-label shortcode protection. |
| tests/wpunit/FormArgumentsEscapingTest.php | Tests form-level argument escaping. |
| tests/wpunit/FieldRenderEscapingTest.php | Adds broad field-rendering injection checks. |
| tests/wpunit/EscapeOutputSuppressionsTest.php | Checks escaping-suppression explanations and counts. |
| tests/wpunit/CalculatedMetaFormulaTest.php | Tests safe metadata insertion into formulas. |
| tests/wpunit/AdminColumnsFuzzTest.php | Checks admin columns for active markup. |
| tests/wpunit/AdminColumnCellHtmlTest.php | Tests cell sanitization and formatting compatibility. |
| tests/wpunit/AddonsDescriptionSanitizationTest.php | Tests remote add-on description sanitization. |
| tests/_data/url-scheme-corpus.json | Shares URL cases between PHP and JavaScript checks. |
| templates/fields/textarea-field.php | Neutralizes shortcodes in preset textarea content. |
| templates/common/start-form-row.php | Documents existing output-escaping safeguards. |
| templates/common/field-description.php | Clarifies the escaping-suppression comment. |
| templates/common/end-form.php | Documents form-ID integer conversion. |
| modules/wysiwyg/blocks/wysiwyg/block-template.php | Neutralizes preset brackets after editor escaping. |
| modules/validation/ssr/ssr-registry-migration-notice.php | Clarifies existing escaping comments. |
| modules/validation/rules-controller.php | Escapes fatal error messages. |
| modules/validation/module.php | Casts inline-script form IDs to integers. |
| modules/shortcode/assets/build/block.editor.asset.php | Updates editor asset cache version. |
| modules/rich-content/module.php | Adds HTML-aware processing and preset protections. |
| modules/rich-content/macros-parser.php | Adds field-value callbacks for email escaping. |
| modules/rich-content/macro-runtime-values.php | Tracks per-pass escaping and neutralization flags. |
| modules/rest-api/endpoints/install-migrations-endpoint.php | Sanitizes migration error responses. |
| modules/post-type/actions/traits/import-form-trait.php | Escapes import failure messages. |
| modules/post-type/actions/import-action.php | Explains an existing output suppression. |
| modules/option-field/blocks/select/block-template.php | Neutralizes generated select-label shortcodes. |
| modules/option-field/blocks/radio/block-render.php | Protects generated radio labels. |
| modules/option-field/blocks/checkbox/block-render.php | Protects generated checkbox labels. |
| modules/option-field/assets/build/editor.asset.php | Updates editor asset cache version. |
| modules/onboarding/use-form/rest-api/use-form-route/use-form-endpoint.php | Sanitizes onboarding error responses. |
| modules/onboarding/use-form/assets/build/index.asset.php | Updates onboarding asset cache version. |
| modules/media-cleanup/media-ownership-migration-notice.php | Clarifies an existing escaping comment. |
| modules/html-parser/assets/src/parseHTMLtoBlocks.js | Parses HTML in an inert template. |
| modules/html-parser/assets/src/getFormInnerFields.js | Restricts attributes and uses inert parsing. |
| modules/html-parser/assets/build/parser.asset.php | Updates parser asset cache version. |
| modules/gateways/paypal/scenarios-logic/pay-now.php | Cleans payer and shipping data before storage. |
| modules/gateways/paypal/rest-endpoints/fetch-pay-now-editor.php | Sanitizes PayPal error responses. |
| modules/gateways/pages/export-page.php | Escapes payment export errors. |
| modules/framework/blocks-style-manager/style-inserter.php | Protects inline style wrappers. |
| modules/form-record/rest-endpoints/mark-view-record-base-endpoint.php | Sanitizes record-update error responses. |
| modules/form-record/admin/pages/export-page.php | Escapes form-record export errors. |
| modules/components/assets/build/index.asset.php | Updates component asset cache version. |
| modules/captcha/module.php | Casts inline-script form IDs to integers. |
| modules/blocks-v2/text-field/assets/build/editor.asset.php | Updates text-field editor cache version. |
| modules/blocks-v2/repeater-field/block-type.php | Inserts metadata into formulas as data. |
| modules/blocks-v2/phone-field/block-template.php | Escapes phone-field attributes. |
| modules/block-parsers/fields/hidden-field-parser.php | Tracks hidden-value provenance for email escaping. |
| modules/ai/rest-api/endpoints/generate-form-endpoint.php | Sanitizes AI-service error responses. |
| modules/advanced-choices/block-renders/choice-control-render.php | Sanitizes choice-control label markup. |
| modules/admin/module.php | Escapes translated deactivation-modal content. |
| modules/active-campaign/rest-api/active-campaign/active-campaign-endpoint.php | Sanitizes ActiveCampaign error responses. |
| modules/actions-v2/send-email/send-email-hooks.php | Uses HTML-aware processing for HTML emails. |
| modules/actions-v2/send-email/assets/build/editor.asset.php | Updates email editor cache version. |
| modules/actions-v2/redirect-to-page/redirect-to-page-action.php | Validates resolved redirect schemes. |
| modules/actions-v2/redirect-to-page/assets/build/editor.asset.php | Updates redirect editor cache version. |
| modules/actions-v2/mailchimp/rest-api/mailchimp/mailchimp-endpoint.php | Sanitizes Mailchimp error responses. |
| modules/actions-v2/mailchimp/assets/build/editor.asset.php | Updates Mailchimp editor cache version. |
| modules/actions-v2/get-response/rest-api/get-response/get-response-endpoint.php | Sanitizes GetResponse error responses. |
| modules/actions-v2/get-response/assets/build/editor.asset.php | Updates GetResponse editor cache version. |
| modules/actions-v2/assets/build/editor.asset.php | Updates actions editor cache version. |
| includes/form-break.php | Escapes progress-wrapper attributes. |
| includes/db-queries/query-conditions-builder.php | Explains an existing diagnostic-output suppression. |
| includes/db-queries/execution-builder.php | Explains an existing diagnostic-output suppression. |
| includes/classes/tools.php | Adds CSS, formula, and macro protection helpers. |
| includes/classes/gallery.php | Uses URL escaping for gallery links and images. |
| includes/classes/base-attributes-trait.php | Documents existing attribute escaping. |
| includes/classes/arrayable/array-convert-once.php | Explains an existing error-output suppression. |
| includes/blocks/types/base.php | Uses HTML-aware processing for rich attributes. |
| includes/blocks/render/media-field-render.php | Neutralizes shortcodes in media previews. |
| includes/blocks/render/form-builder.php | Protects inline CSS and its form-ID attribute. |
| includes/blocks/render/calculated-field-render.php | Safely inserts metadata into calculated formulas. |
| includes/blocks/render/base.php | Adds generated-option label protection. |
| includes/blocks/module.php | Supplies allowed URL protocols to the frontend. |
| includes/admin/table-views/column-base.php | Sanitizes HTML in string-type table cells. |
| includes/admin/single-pages/base-page-updater.php | Sanitizes admin update error responses. |
| includes/admin/pages/single-pages-manager.php | Escapes standalone-page errors. |
| includes/admin/pages/action-pages-manager.php | Escapes action-page errors and access messages. |
| includes/addons/manager.php | Sanitizes remote descriptions and activation errors. |
| components/rest-api/rest-api-controller-base.php | Explains an existing diagnostic-output suppression. |
| components/admin/buttons/base-vui-button.php | Explains an existing error-output suppression. |
| compatibility/jet-popup/jet-popup.php | Protects popup inline CSS. |
| compatibility/jet-engine/jet-engine.php | Unslashes and cleans scalar relation inputs. |
| compatibility/jet-engine/blocks/map-field/assets/src/frontend/map.field/signal.js | Builds map previews with DOM text. |
| compatibility/jet-engine/blocks/map-field/assets/build/frontend/map.js | Includes the map-preview protection. |
| compatibility/jet-engine/blocks/map-field/assets/build/frontend/map.asset.php | Updates map frontend cache version. |
| compatibility/jet-engine/blocks/check-mark/assets/build/editor.asset.php | Updates check-mark editor cache version. |
| compatibility/jet-engine/assets/build/editor.asset.php | Updates JetEngine editor cache version. |
| compatibility/elementor/widgets/form.php | Documents existing renderer escaping. |
| compatibility/bricks/widgets/form.php | Documents existing wrapper and renderer escaping. |
| assets/src/package/validation/store/reducer.js | Escapes callback names in editor summaries. |
| assets/src/package/preset/helpers/humanReadablePreset.js | Escapes values in preset-summary HTML. |
| assets/src/package/preset/helpers/escapeText.js | Adds a shared editor text-escaping helper. |
| assets/src/package/block-conditions/store/reducer.js | Escapes condition fields and states. |
| assets/src/frontend/media.field/signal.js | Escapes apostrophes in preview placeholders. |
| assets/src/frontend/main/html.macro/observeMacroAttr.js | Guards macro attribute assignments and URLs. |
| assets/src/frontend/main/html.macro/macroUrl.js | Adds URL-scheme and forbidden-attribute checks. |
| assets/src/frontend/main/html.macro/CalculatedHtmlString.js | Sanitizes assembled HTML while preserving trusted fragments. |
| assets/src/frontend/main/functions.js | Documents safe use of the HTML-parsing API. |
| assets/src/frontend/calculated.field/functions.js | Replaces timestamp eval() with numeric conversion. |
| assets/src/admin-vuex-package/components/TableColumns/link-type/LinkType.vue | Blocks script-like schemes in admin links. |
| assets/build/frontend/media.field.js | Includes media-preview escaping changes. |
| assets/build/frontend/media.field.asset.php | Updates media-field cache version. |
| assets/build/frontend/main.asset.php | Updates main frontend cache version. |
| assets/build/frontend/calculated.field.js | Includes numeric timestamp conversion. |
| assets/build/frontend/calculated.field.asset.php | Updates calculated-field cache version. |
| assets/build/editor/package.asset.php | Updates editor package cache version. |
| assets/build/editor/form.builder.asset.php | Updates form-builder editor cache version. |
| assets/build/admin/vuex.package.asset.php | Updates admin Vue package cache version. |
| assets/build/admin/package.asset.php | Updates admin package cache version. |
| .gitignore | Allows tracking the security tests and URL corpus. |
Review effort: Balanced
| public static function neutralize_shortcodes( string $value ): string { | ||
| return str_replace( array( '[', ']' ), array( '[', ']' ), $value ); |
🤖 AI PR ReviewRisk level: ReviewSummary
What I reviewed (high level)
Good security improvements
Files/areas I inspected specifically
Issues, questions & recommendations
Minor style / code suggestions
Conclusion
Files I recommend adding tests for (at minimum)
If you'd like, I can draft Jest test cases for the above behaviors. Suggested changelog entry
|
🤖 AI PR ReviewRisk level: ReviewSummary
What I inspected (high level)
Security review / issues found
Backward compatibility concerns
Multisite / integrations
Tests
Other small notes
Suggested action items before merge
Overall assessment
Suggested changelog entry
|
🤖 AI PR ReviewRisk level: ReviewSummary
What I checked
Files of interest (high-level)
Security review/comments
Points to verify / suggestions
Performance
Backward compatibility
Tests missing / recommended
Minor code suggestions
Summary recommendation
Overall: good work — addresses important XSS issues and improves sanitization throughout the JS codebase. Suggested changelog entry
|
🤖 AI PR ReviewRisk level: ReviewSummary
Files / functions to pay attention to
Security review / notes
Important items to verify (action items for author / release)
Performance / bundle notes
Other suggestions
Build / release checklist
Conclusion
Minor: I noticed modern APIs like String.prototype.replaceAll are used (fine for supported browsers). If you support older browsers this may require polyfills. Suggested changelog entry
|
There was a problem hiding this comment.
🟡 Changes recommended
Formula scanning misinterprets quotes in regex literals and changes calculation results, while the shortcode matrix test can pass despite callbacks executing inside input attributes.
3 open issues
3 resolved since last review
4 files not reviewed
assets/build/admin/package.js: Generated fileassets/build/frontend/calculated.field.js: Generated fileassets/build/frontend/dynamic.value.js: Generated fileassets/build/frontend/media.field.js: Generated file
Review effort: Balanced
| return ''; | ||
| } | ||
|
|
||
| $in_string = Tools::formula_macro_string_contexts( (string) $args['calc_formula'] ); |
| * @dataProvider fieldProvider | ||
| */ | ||
| public function testPresetValueStaysData( string $block, array $attrs, bool $use_preset = true ): void { | ||
| $html = $this->render( $block, $attrs, $use_preset ); |
🤖 AI PR ReviewRisk level: ReviewSummary
What I checked / highlights
Files called out (key changes)
Security aspects
Backward compatibility / behavior changes to watch for
Potential issues / suggestions
Missing tests / CI
Conclusion
Minor / style notes
Recommendation: Approve after adding (or pointing to) tests and confirming sanitizeHtml availability and behavior. Suggested changelog entry
|


Issue - https://github.com/Crocoblock/issues-tracker/issues/20753