@salesforce/afv-skills 1.36.0 → 1.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/agentforce-generate/README.md +20 -3
- package/skills/agentforce-generate/SKILL.md +253 -440
- package/skills/agentforce-generate/assets/agent-spec-template.md +6 -2
- package/skills/agentforce-generate/assets/agents/order-service.agent +16 -12
- package/skills/agentforce-generate/assets/agents/production-faq.agent +4 -4
- package/skills/agentforce-generate/assets/agents/router-first.agent +5 -5
- package/skills/agentforce-generate/assets/agents/template-single-subagent.agent +4 -4
- package/skills/agentforce-generate/assets/agents/verification-gate.agent +8 -6
- package/skills/agentforce-generate/assets/agents/voice-knowledge-grounded.agent +9 -9
- package/skills/agentforce-generate/assets/agents/voice-service-agent.agent +7 -7
- package/skills/agentforce-generate/assets/patterns/README.md +3 -3
- package/skills/agentforce-generate/assets/patterns/action-callbacks.agent +5 -5
- package/skills/agentforce-generate/assets/patterns/advanced-input-bindings.agent +6 -8
- package/skills/agentforce-generate/assets/patterns/bidirectional-routing.agent +11 -13
- package/skills/agentforce-generate/assets/patterns/critical-input-collection.agent +11 -16
- package/skills/agentforce-generate/assets/patterns/lifecycle-events.agent +2 -3
- package/skills/agentforce-generate/assets/patterns/llm-controlled-actions.agent +6 -7
- package/skills/agentforce-generate/assets/patterns/open-gate-routing.agent +3 -3
- package/skills/agentforce-generate/assets/patterns/prompt-template-action.agent +14 -19
- package/skills/agentforce-generate/assets/patterns/system-instruction-overrides.agent +11 -20
- package/skills/agentforce-generate/references/actions-reference.md +2 -2
- package/skills/agentforce-generate/references/agent-audit-and-repair.md +135 -0
- package/skills/agentforce-generate/references/agent-audit-candidate-verification.md +160 -0
- package/skills/agentforce-generate/references/agent-audit-diagnostic-catalog.md +156 -0
- package/skills/agentforce-generate/references/agent-audit-diagnostics-actions-state.md +176 -0
- package/skills/agentforce-generate/references/agent-audit-diagnostics-architecture-evaluation.md +68 -0
- package/skills/agentforce-generate/references/agent-audit-diagnostics-instructions-routing.md +283 -0
- package/skills/agentforce-generate/references/agent-audit-evaluation-loop.md +191 -0
- package/skills/agentforce-generate/references/agent-audit-repair-report.md +143 -0
- package/skills/agentforce-generate/references/agent-audit-scope-path-review.md +180 -0
- package/skills/agentforce-generate/references/agent-design-and-spec-creation.md +105 -59
- package/skills/agentforce-generate/references/agent-script-core-language.md +144 -61
- package/skills/agentforce-generate/references/agent-subagent-map-diagrams.md +33 -23
- package/skills/agentforce-generate/references/agent-validation-and-debugging.md +37 -11
- package/skills/agentforce-generate/references/agentscript-toolchain.md +112 -0
- package/skills/agentforce-generate/references/architecture-patterns.md +81 -18
- package/skills/agentforce-generate/references/common-control-flow-pitfalls.md +255 -0
- package/skills/agentforce-generate/references/control-flow-actions-sequencing.md +198 -0
- package/skills/agentforce-generate/references/control-flow-lifecycle-side-effects.md +87 -0
- package/skills/agentforce-generate/references/examples.md +22 -22
- package/skills/agentforce-generate/references/instruction-resolution.md +123 -83
- package/skills/agentforce-generate/references/known-issues.md +1 -2
- package/skills/agentforce-generate/references/optimization-pattern-1-data-flow.md +4 -0
- package/skills/agentforce-generate/references/optimization-pattern-2-deterministic-logic.md +33 -0
- package/skills/agentforce-generate/references/optimization-pattern-3-reference-syntax.md +32 -3
- package/skills/agentforce-generate/references/optimization-pattern-4-escalation.md +2 -2
- package/skills/agentforce-generate/references/patterns-by-requirement.md +3 -1
- package/skills/agentforce-generate/references/posture-and-determinism.md +103 -22
- package/skills/agentforce-generate/references/reference-map.md +19 -3
- package/skills/agentforce-generate/references/scoring-rubric.md +1 -1
- package/skills/agentforce-generate/references/voice-latency-heuristics.md +4 -0
- package/skills/agentforce-generate/references/voice-modality-reference.md +4 -4
- package/skills/agentforce-generate/references/zen-of-agentscript.md +139 -23
- package/skills/agentforce-generate/scripts/agentscript-sdk-loader.mjs +133 -0
- package/skills/agentforce-generate/scripts/index-agent.mjs +141 -0
- package/skills/agentforce-generate/scripts/setup-agentscript-sdk.mjs +337 -0
- package/skills/automation-sandbox-post-copy-config-generate/SKILL.md +1 -1
- package/skills/automation-sandbox-post-copy-configure/SKILL.md +433 -0
- package/skills/automation-sandbox-post-copy-configure/assets/api_request_templates.json +89 -0
- package/skills/automation-sandbox-post-copy-configure/examples/sample_config_input.json +40 -0
- package/skills/automation-sandbox-post-copy-configure/examples/sample_execution_summary.md +79 -0
- package/skills/automation-sandbox-post-copy-configure/references/api_endpoints.md +273 -0
- package/skills/automation-sandbox-post-copy-configure/references/authentication.md +94 -0
- package/skills/automation-sandbox-post-copy-configure/references/execution_phasing.md +93 -0
- package/skills/automation-sandbox-post-copy-configure/references/rules_gotchas.md +35 -0
- package/skills/automation-sandbox-post-copy-configure/scripts/classify-patch-result.mjs +88 -0
- package/skills/automation-sandbox-post-copy-configure/scripts/map-metadata-key.mjs +98 -0
- package/skills/automation-sandbox-post-copy-configure/scripts/plan-phases.mjs +98 -0
- package/skills/automation-sandbox-post-copy-configure/scripts/resolve-target-org.mjs +56 -0
- package/skills/design-systems-slds-validate/SKILL.md +14 -13
- package/skills/dx-code-analyzer-custom-rule-create/examples/xpath-examples.md +1 -1
- package/skills/dx-code-analyzer-custom-rule-create/references/xpath-patterns-security.md +1 -1
- package/skills/dx-org-devhub-configure/SKILL.md +268 -0
- package/skills/dx-org-devhub-configure/examples/status-output.md +39 -0
- package/skills/dx-org-devhub-configure/scripts/devhub.sh +650 -0
- package/skills/dx-org-devhub-configure/scripts/test-devhub.sh +116 -0
- package/skills/dx-org-manage/SKILL.md +135 -42
- package/skills/dx-org-manage/assets/derive-alias.sh +95 -0
- package/skills/dx-org-manage/assets/scratch-def.seed.json +6 -0
- package/skills/dx-org-manage/examples/README.md +1 -1
- package/skills/dx-org-manage/examples/scratch-orgs/delete_output.json +8 -0
- package/skills/dx-org-manage/examples/scratch-orgs/display_output.json +23 -0
- package/skills/dx-org-manage/examples/scratch-orgs/list_output.json +58 -0
- package/skills/dx-org-manage/examples/scratch-orgs/resume_output.json +38 -0
- package/skills/dx-org-manage/examples/scratch-orgs/success_definition_file.json +1 -1
- package/skills/dx-org-manage/examples/scratch-orgs/success_edition.json +1 -1
- package/skills/dx-org-manage/examples/scratch-orgs/success_shape.json +41 -0
- package/skills/dx-org-manage/examples/scratch-orgs/success_snapshot.json +1 -1
- package/skills/dx-org-manage/examples/snapshots/error_output.json +3 -3
- package/skills/dx-org-manage/references/creating-scratch-org.md +2 -2
- package/skills/dx-org-manage/references/creating-snapshot.md +1 -2
- package/skills/dx-org-manage/references/definition_file_options.md +24 -0
- package/skills/dx-org-manage/references/edition_types.md +10 -8
- package/skills/dx-org-manage/references/opening-org.md +11 -12
- package/skills/dx-org-manage/references/scratch-org-create.md +303 -0
- package/skills/dx-org-manage/references/scratch-org-operations.md +135 -0
- package/skills/experience-aura-lwc-migrate/SKILL.md +120 -0
- package/skills/experience-aura-lwc-migrate/references/aura-api-expert.md +170 -0
- package/skills/experience-aura-lwc-migrate/references/aura-data-expert.md +172 -0
- package/skills/experience-aura-lwc-migrate/references/aura-migration-guidelines.md +299 -0
- package/skills/experience-aura-lwc-migrate/references/aura-prd-framework.md +79 -0
- package/skills/experience-aura-lwc-migrate/references/aura-redundant-code-expert.md +24 -0
- package/skills/experience-aura-lwc-migrate/references/aura-reference-expert.md +140 -0
- package/skills/experience-aura-lwc-migrate/references/aura-resolver-expert.md +115 -0
- package/skills/experience-aura-lwc-migrate/references/aura-slots-expert.md +67 -0
- package/skills/experience-aura-lwc-migrate/references/aura-style-expert.md +62 -0
- package/skills/experience-aura-lwc-migrate/references/aura-to-lwc-completeness-checklist.md +188 -0
- package/skills/experience-aura-lwc-migrate/references/aura-values-expert.md +67 -0
- package/skills/experience-content-media-search/SKILL.md +17 -12
- package/skills/experience-content-media-stock-image-search/SKILL.md +192 -0
- package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +102 -0
- package/skills/experience-lds-best-practices-apply/SKILL.md +245 -0
- package/skills/experience-lds-best-practices-apply/references/adapter-apis.md +1640 -0
- package/skills/experience-lds-best-practices-apply/references/lds-data-consistency.md +126 -0
- package/skills/experience-lds-best-practices-apply/references/lds-expert.md +429 -0
- package/skills/experience-lds-best-practices-apply/references/lds-referential-integrity.md +322 -0
- package/skills/experience-lds-best-practices-apply/references/wire-adapter-types.md +1511 -0
- package/skills/experience-lds-graphql-generate/SKILL.md +222 -0
- package/skills/experience-lds-graphql-generate/references/generation-guide.md +236 -0
- package/skills/experience-lds-graphql-generate/references/generation-mutation.md +277 -0
- package/skills/experience-lds-graphql-generate/references/generation-query.md +237 -0
- package/skills/experience-lds-graphql-generate/scripts/fetch-lds-graphql-schema.sh +230 -0
- package/skills/experience-lds-graphql-generate/scripts/test-lds-graphql-query.sh +128 -0
- package/skills/experience-lwc-accessibility-validate/SKILL.md +112 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-1-1-non-text-content.md +88 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-i-lists.md +52 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-ii-tables.md +106 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iii-form-labels.md +78 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iv-regions.md +26 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-v-groups.md +66 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-5-identify-input.md +70 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-4-3-contrast.md +115 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-1-1-keyboard.md +47 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-4-link-purpose.md +39 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-6-headings-labels.md +50 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-1-pointer-gestures.md +54 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-2-pointer-cancellation.md +49 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-3-label-in-name.md +77 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-7-dragging-movement.md +45 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-1-on-focus.md +55 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-2-on-input.md +51 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-1-error-identification.md +84 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-2-labels-instructions.md +50 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-3-error-suggestion.md +64 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-i-name.md +105 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-ii-role.md +99 -0
- package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-iii-value.md +97 -0
- package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-1-1-non-text-content.md +83 -0
- package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-1-use-of-color.md +62 -0
- package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-10-resize-reflow.md +18 -0
- package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-11-non-text-contrast.md +43 -0
- package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-3-contrast.md +25 -0
- package/skills/experience-lwc-accessibility-validate/scripts/contrast-ratio.py +153 -0
- package/skills/experience-lwc-design-generate/SKILL.md +261 -0
- package/skills/experience-lwc-design-generate/references/figma-to-prd-blueprint.md +66 -0
- package/skills/experience-lwc-design-generate/references/prd-analysis-template.md +17 -0
- package/skills/experience-lwc-design-generate/scripts/check-component-name.sh +75 -0
- package/skills/experience-lwc-design-generate/scripts/detect-project-tools.sh +97 -0
- package/skills/experience-lwc-runtime-observe/SKILL.md +244 -0
- package/skills/experience-lwc-runtime-observe/examples/component-preview-and-dom.md +41 -0
- package/skills/experience-lwc-runtime-observe/scripts/extract-dom.sh +79 -0
- package/skills/experience-lwc-runtime-observe/scripts/open-frontdoor.sh +46 -0
- package/skills/experience-lwc-runtime-observe/scripts/verify-toolchain.sh +48 -0
- package/skills/experience-lwc-security-validate/SKILL.md +151 -0
- package/skills/experience-lwc-security-validate/examples/review-report.md +6 -0
- package/skills/experience-lwc-security-validate/examples/score-report.sarif.json +32 -0
- package/skills/experience-lwc-security-validate/references/lws-security-expert.md +986 -0
- package/skills/experience-lwc-security-validate/references/security-analysis.md +611 -0
- package/skills/experience-lwc-security-validate/scripts/check-lwc-import.sh +166 -0
- package/skills/experience-lwc-security-validate/scripts/validate-sarif.sh +131 -0
- package/skills/experience-lwr-site-generate/SKILL.md +1 -2
- package/skills/experience-ui-bundle-2gp-deploy/SKILL.md +454 -0
- package/skills/experience-ui-bundle-2gp-deploy/assets/CustomApplication.app-meta.xml +12 -0
- package/skills/experience-ui-bundle-2gp-deploy/assets/PermissionSet.permissionset-meta.xml +9 -0
- package/skills/experience-ui-bundle-2gp-deploy/scripts/find-bundle-package-dir.sh +53 -0
- package/skills/experience-ui-bundle-agentforce-client-generate/SKILL.md +104 -26
- package/skills/experience-ui-bundle-agentforce-client-generate/references/constraints.md +35 -24
- package/skills/experience-ui-bundle-agentforce-client-generate/references/examples.md +92 -1
- package/skills/experience-ui-bundle-agentforce-client-generate/references/style-tokens.md +2 -0
- package/skills/experience-ui-bundle-agentforce-client-generate/references/troubleshooting.md +14 -1
- package/skills/experience-ui-bundle-agentforce-client-generate/scripts/detect-framework.sh +67 -0
- package/skills/experience-ui-bundle-deploy/SKILL.md +83 -14
- package/skills/experience-ui-bundle-deploy/assets/Communities.settings-meta.xml +19 -0
- package/skills/experience-ui-bundle-deploy/assets/org-setup.config.template.json +5 -0
- package/skills/experience-ui-bundle-deploy/assets/social-login-auth-providers.apex +158 -0
- package/skills/experience-ui-bundle-deploy/references/config-scaffold.md +13 -1
- package/skills/experience-ui-bundle-deploy/references/social-login.md +179 -0
- package/skills/experience-ui-bundle-frontend-generate/SKILL.md +14 -0
- package/skills/experience-ui-bundle-mfa-configure/SKILL.md +6 -5
- package/skills/experience-ui-bundle-mfa-configure/references/social-login.md +15 -7
- package/skills/experience-ui-bundle-salesforce-data-access/SKILL.md +41 -5
- package/skills/experience-ui-bundle-salesforce-data-access/references/caching.md +10 -22
- package/skills/experience-ui-bundle-salesforce-data-access/references/graphql-hand-authoring.md +4 -19
- package/skills/experience-ui-bundle-salesforce-data-access/references/migration.md +5 -0
- package/skills/experience-ui-bundle-salesforce-data-access/references/sdk-api.md +33 -150
- package/skills/mobile-platform-native-capabilities-integrate/references/nfc.md +35 -0
- package/skills/platform-apex-generate/SKILL.md +8 -7
- package/skills/platform-apex-test-generate/SKILL.md +3 -1
- package/skills/platform-apex-test-run/SKILL.md +9 -8
- package/skills/platform-custom-field-generate/SKILL.md +7 -1
- package/skills/platform-lightning-app-coordinate/SKILL.md +3 -3
- package/skills/platform-lightning-type-widget-coordinate/SKILL.md +1 -1
- package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +1 -1
- package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +1 -1
- package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +3 -3
- package/skills/platform-mcp-tool-widget-coordinate/SKILL.md +43 -67
- package/skills/platform-mcp-tool-widget-coordinate/examples/action-name-source-prompt.md +1 -2
- package/skills/platform-mcp-tool-widget-coordinate/examples/apex-invocable-source-prompt.md +2 -3
- package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-list-source-prompt.md +163 -0
- package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-single-source-prompt.md +198 -0
- package/skills/platform-mcp-tool-widget-coordinate/examples/pasted-tool-output-prompt.md +0 -1
- package/skills/platform-mcp-tool-widget-coordinate/references/build-plan-format.md +17 -11
- package/skills/platform-mcp-tool-widget-coordinate/references/mcp-tool-output-discovery.md +48 -15
- package/skills/platform-mcp-tool-widget-coordinate/references/two-clt-modeling.md +73 -10
- package/skills/platform-mcp-tool-widget-coordinate/references/validation-gates.md +48 -8
- package/skills/platform-policy-rule-generate/SKILL.md +22 -12
- package/skills/platform-policy-rule-generate/references/deploy-errors.md +1 -1
- package/skills/platform-policy-rule-generate/references/policy-schema-full.md +8 -29
- package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
- package/skills/platform-report-generate/SKILL.md +1 -1
- package/skills/platform-sharing-owd-configure/SKILL.md +20 -8
- package/skills/platform-sharing-owd-configure/references/access_levels.md +14 -1
- package/skills/platform-sharing-rules-generate/SKILL.md +67 -35
- package/skills/platform-sharing-rules-generate/examples/create-cases.md +16 -17
- package/skills/platform-sharing-rules-generate/examples/delete-cases.md +34 -79
- package/skills/platform-sharing-rules-generate/examples/edit-cases.md +13 -26
- package/skills/platform-sharing-rules-generate/scripts/count-remaining-rules.sh +33 -0
- package/skills/platform-value-set-generate/SKILL.md +6 -2
- package/skills/platform-widget-generate/SKILL.md +3 -5
- package/skills/platform-widget-generate/examples/conditional.json +18 -13
- package/skills/platform-widget-generate/examples/list-with-foreach.json +2 -2
- package/skills/platform-widget-generate/examples/single-object.json +2 -2
- package/skills/platform-widget-generate/references/schema-from-lightning-type.md +27 -6
- package/skills/platform-widget-generate/references/widget-bundle-layout.md +4 -3
- package/skills/service-itsm-agentic-setup-cmdb-access-assign/SKILL.md +287 -0
- package/skills/service-itsm-agentic-setup-cmdb-access-assign/references/mcp-invocation.md +260 -0
- package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/SKILL.md +252 -0
- package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/references/mcp-invocation.md +204 -0
- package/skills/service-itsm-agentic-setup-cmdb-configure/SKILL.md +259 -0
- package/skills/service-itsm-agentic-setup-cmdb-configure/references/mcp-invocation.md +188 -0
- package/skills/service-itsm-agentic-setup-cmdb-coordinate/SKILL.md +197 -0
- package/skills/service-itsm-agentic-setup-cmdb-coordinate/examples/output-templates.md +77 -0
- package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/SKILL.md +316 -0
- package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/references/mcp-invocation.md +221 -0
- package/skills/service-itsm-incident-priority-configure/SKILL.md +168 -0
- package/skills/service-itsm-incident-priority-configure/examples/matrix-operations.md +200 -0
- package/skills/service-itsm-incident-priority-configure/examples/render-matrix.md +54 -0
- package/skills/service-itsm-incident-priority-configure/examples/seed-full-matrix.md +52 -0
- package/skills/service-itsm-incident-priority-configure/references/sf-cli-invocation.md +264 -0
- package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-source-prompt.md +0 -191
- package/skills/platform-policy-rule-generate/references/fixtures-index.md +0 -29
|
@@ -0,0 +1,986 @@
|
|
|
1
|
+
# LWSExpert
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Use this tool to make LWC code secure.
|
|
6
|
+
|
|
7
|
+
## Knowledge Base
|
|
8
|
+
|
|
9
|
+
## Lightning Web Security (LWS) Analysis Assistant
|
|
10
|
+
|
|
11
|
+
The following topics, each with their own grounding, are separated by a line of dashes and a new H1 header. Treat each topic as a separate grounding.
|
|
12
|
+
These topics can be used to analyze any Lightning Web Components code, as well as any JavaScript or TypeScript code. The code being analyzed DOES NOT HAVE TO BE LWC CODE.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
The following definitions are CRITICAL, DO NOT IGNORE THEM:
|
|
17
|
+
|
|
18
|
+
- "Built-in object" refers to any object that is part of the core JavaScript language.
|
|
19
|
+
- "Host object" refers to any object that is not a built-in object or a custom object created by the component. Host objects are defined by the "Web API" or "DOM API"
|
|
20
|
+
- "Web API" or "DOM API" refers to the set of objects and methods defined by the HTML and DOM standards and includes all of the following: AbortController, AbortSignal, AbsoluteOrientationSensor, AbstractRange, Accelerometer, AICreateMonitor, alert, AnalyserNode, Animation, AnimationEffect, AnimationEvent, AnimationPlaybackEvent, AnimationTimeline, AsyncDisposableStack, atob, Attr, Audio, AudioBuffer, AudioBufferSourceNode, AudioContext, AudioData, AudioDecoder, AudioDestinationNode, AudioEncoder, AudioListener, AudioNode, AudioParam, AudioParamMap, AudioProcessingEvent, AudioScheduledSourceNode, AudioSinkInfo, AudioWorklet, AudioWorkletNode, AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, AuthenticatorResponse, BackgroundFetchManager, BackgroundFetchRecord, BackgroundFetchRegistration, BarcodeDetector, BarProp, BaseAudioContext, BatteryManager, BeforeInstallPromptEvent, BeforeUnloadEvent, BiquadFilterNode, Blob, BlobEvent, Bluetooth, BluetoothCharacteristicProperties, BluetoothDevice, BluetoothRemoteGATTCharacteristic, BluetoothRemoteGATTDescriptor, BluetoothRemoteGATTServer, BluetoothRemoteGATTService, BluetoothUUID, blur, BroadcastChannel, BrowserCaptureMediaStreamTrack, btoa, ByteLengthQueuingStrategy, Cache, caches, CacheStorage, cancelAnimationFrame, cancelIdleCallback, CanvasCaptureMediaStreamTrack, CanvasGradient, CanvasPattern, CanvasRenderingContext2D, CaptureController, captureEvents, CaretPosition, CDATASection, ChannelMergerNode, ChannelSplitterNode, ChapterInformation, CharacterBoundsUpdateEvent, CharacterData, chrome, clearInterval, clearTimeout, clientInformation, Clipboard, ClipboardEvent, ClipboardItem, close, closed, CloseEvent, CloseWatcher, CommandEvent, Comment, CompositionEvent, CompressionStream, confirm, console, ConstantSourceNode, ContentVisibilityAutoStateChangeEvent, ConvolverNode, CookieChangeEvent, cookieStore, CookieStore, CookieStoreManager, CountQueuingStrategy, createImageBitmap, Credential, credentialless, CredentialsContainer, CropTarget, crossOriginIsolated, crypto, Crypto, CryptoKey, CSPViolationReportBody, CSS, CSSAnimation, CSSConditionRule, CSSContainerRule, CSSCounterStyleRule, CSSFontFaceRule, CSSFontFeatureValuesRule, CSSFontPaletteValuesRule, CSSGroupingRule, CSSImageValue, CSSImportRule, CSSKeyframeRule, CSSKeyframesRule, CSSKeywordValue, CSSLayerBlockRule, CSSLayerStatementRule, CSSMarginRule, CSSMathClamp, CSSMathInvert, CSSMathMax, CSSMathMin, CSSMathNegate, CSSMathProduct, CSSMathSum, CSSMathValue, CSSMatrixComponent, CSSMediaRule, CSSNamespaceRule, CSSNestedDeclarations, CSSNumericArray, CSSNumericValue, CSSPageRule, CSSPerspective, CSSPositionTryDescriptors, CSSPositionTryRule, CSSPositionValue, CSSPropertyRule, CSSRotate, CSSRule, CSSRuleList, CSSScale, CSSScopeRule, CSSSkew, CSSSkewX, CSSSkewY, CSSStartingStyleRule, CSSStyleDeclaration, CSSStyleRule, CSSStyleSheet, CSSStyleValue, CSSSupportsRule, CSSTransformComponent, CSSTransformValue, CSSTransition, CSSTranslate, CSSUnitValue, CSSUnparsedValue, CSSVariableReferenceValue, CSSViewTransitionRule, CustomElementRegistry, customElements, CustomEvent, CustomStateSet, DataTransfer, DataTransferItem, DataTransferItemList, DecompressionStream, DelayNode, DelegatedInkTrailPresenter, DeviceMotionEvent, DeviceMotionEventAcceleration, DeviceMotionEventRotationRate, DeviceOrientationEvent, devicePixelRatio, DevicePosture, DisposableStack, document, Document, DocumentFragment, documentPictureInPicture, DocumentPictureInPicture, DocumentPictureInPictureEvent, DocumentTimeline, DocumentType, DOMError, DOMException, DOMImplementation, DOMMatrix, DOMMatrixReadOnly, DOMParser, DOMPoint, DOMPointReadOnly, DOMQuad, DOMRect, DOMRectList, DOMRectReadOnly, DOMStringList, DOMStringMap, DOMTokenList, DragEvent, DynamicsCompressorNode, EditContext, Element, ElementInternals, EncodedAudioChunk, EncodedVideoChunk, ErrorEvent, event, Event, EventCounts, EventSource, EventTarget, external, External, EyeDropper, FeaturePolicy, FederatedCredential, fence, Fence, FencedFrameConfig, fetch, fetchLater, FetchLaterResult, File, FileList, FileReader, FileSystemDirectoryHandle, FileSystemFileHandle, FileSystemHandle, FileSystemObserver, FileSystemWritableFileStream, find, Float16Array, focus, FocusEvent, FontData, FontFace, FontFaceSetLoadEvent, FormData, FormDataEvent, FragmentDirective, frameElement, frames, GainNode, Gamepad, GamepadButton, GamepadEvent, GamepadHapticActuator, Geolocation, GeolocationCoordinates, GeolocationPosition, GeolocationPositionError, getComputedStyle, getScreenDetails, getSelection, GPU, GPUAdapter, GPUAdapterInfo, GPUBindGroup, GPUBindGroupLayout, GPUBuffer, GPUBufferUsage, GPUCanvasContext, GPUColorWrite, GPUCommandBuffer, GPUCommandEncoder, GPUCompilationInfo, GPUCompilationMessage, GPUComputePassEncoder, GPUComputePipeline, GPUDevice, GPUDeviceLostInfo, GPUError, GPUExternalTexture, GPUInternalError, GPUMapMode, GPUOutOfMemoryError, GPUPipelineError, GPUPipelineLayout, GPUQuerySet, GPUQueue, GPURenderBundle, GPURenderBundleEncoder, GPURenderPassEncoder, GPURenderPipeline, GPUSampler, GPUShaderModule, GPUShaderStage, GPUSupportedFeatures, GPUSupportedLimits, GPUTexture, GPUTextureUsage, GPUTextureView, GPUUncapturedErrorEvent, GPUValidationError, GravitySensor, Gyroscope, HashChangeEvent, Headers, HID, HIDConnectionEvent, HIDDevice, HIDInputReportEvent, Highlight, HighlightRegistry, history, History, HTMLAllCollection, HTMLAnchorElement, HTMLAreaElement, HTMLAudioElement, HTMLBaseElement, HTMLBodyElement, HTMLBRElement, HTMLButtonElement, HTMLCanvasElement, HTMLCollection, HTMLDataElement, HTMLDataListElement, HTMLDetailsElement, HTMLDialogElement, HTMLDirectoryElement, HTMLDivElement, HTMLDListElement, HTMLDocument, HTMLElement, HTMLEmbedElement, HTMLFencedFrameElement, HTMLFieldSetElement, HTMLFontElement, HTMLFormControlsCollection, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement, HTMLHeadElement, HTMLHeadingElement, HTMLHRElement, HTMLHtmlElement, HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLLabelElement, HTMLLegendElement, HTMLLIElement, HTMLLinkElement, HTMLMapElement, HTMLMarqueeElement, HTMLMediaElement, HTMLMenuElement, HTMLMetaElement, HTMLMeterElement, HTMLModElement, HTMLObjectElement, HTMLOListElement, HTMLOptGroupElement, HTMLOptionElement, HTMLOptionsCollection, HTMLOutputElement, HTMLParagraphElement, HTMLParamElement, HTMLPictureElement, HTMLPreElement, HTMLProgressElement, HTMLQuoteElement, HTMLScriptElement, HTMLSelectedContentElement, HTMLSelectElement, HTMLSlotElement, HTMLSourceElement, HTMLSpanElement, HTMLStyleElement, HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement, HTMLTableElement, HTMLTableRowElement, HTMLTableSectionElement, HTMLTemplateElement, HTMLTextAreaElement, HTMLTimeElement, HTMLTitleElement, HTMLTrackElement, HTMLUListElement, HTMLUnknownElement, HTMLVideoElement, IDBCursor, IDBCursorWithValue, IDBDatabase, IDBFactory, IDBIndex, IDBKeyRange, IDBObjectStore, IDBOpenDBRequest, IDBRequest, IDBTransaction, IDBVersionChangeEvent, IdentityCredential, IdentityCredentialError, IdentityProvider, IdleDeadline, IdleDetector, IIRFilterNode, Image, ImageBitmap, ImageBitmapRenderingContext, ImageCapture, ImageData, ImageDecoder, ImageTrack, ImageTrackList, indexedDB, Ink, InputDeviceCapabilities, InputDeviceInfo, InputEvent, IntersectionObserver, IntersectionObserverEntry, isSecureContext, Keyboard, KeyboardEvent, KeyboardLayoutMap, KeyframeEffect, LargestContentfulPaint, LaunchParams, launchQueue, LaunchQueue, LayoutShift, LayoutShiftAttribution, LinearAccelerationSensor, localStorage, location, Location, locationbar, Lock, LockManager, matchMedia, MathMLElement, MediaCapabilities, MediaDeviceInfo, MediaDevices, MediaElementAudioSourceNode, MediaEncryptedEvent, MediaError, MediaKeyMessageEvent, MediaKeys, MediaKeySession, MediaKeyStatusMap, MediaKeySystemAccess, MediaList, MediaMetadata, MediaQueryList, MediaQueryListEvent, MediaRecorder, MediaSession, MediaSource, MediaSourceHandle, MediaStream, MediaStreamAudioDestinationNode, MediaStreamAudioSourceNode, MediaStreamEvent, MediaStreamTrack, MediaStreamTrackAudioStats, MediaStreamTrackEvent, MediaStreamTrackGenerator, MediaStreamTrackProcessor, MediaStreamTrackVideoStats, menubar, MessageChannel, MessageEvent, MessagePort, MIDIAccess, MIDIConnectionEvent, MIDIInput, MIDIInputMap, MIDIMessageEvent, MIDIOutput, MIDIOutputMap, MIDIPort, MimeType, MimeTypeArray, MouseEvent, moveBy, moveTo, MutationObserver, MutationRecord, NamedNodeMap, NavigateEvent, navigation, Navigation, NavigationActivation, NavigationCurrentEntryChangeEvent, NavigationDestination, NavigationHistoryEntry, NavigationPreloadManager, NavigationTransition, navigator, Navigator, NavigatorLogin, NavigatorManagedData, NavigatorUAData, NetworkInformation, Node, NodeFilter, NodeIterator, NodeList, Notification, NotRestoredReasonDetails, NotRestoredReasons, Observable, OfflineAudioCompletionEvent, OfflineAudioContext, offscreenBuffering, OffscreenCanvas, OffscreenCanvasRenderingContext2D, onabort, onafterprint, onanimationend, onanimationiteration, onanimationstart, onappinstalled, onauxclick, onbeforeinput, onbeforeinstallprompt, onbeforematch, onbeforeprint, onbeforetoggle, onbeforeunload, onbeforexrselect, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, onclose, oncommand, oncontentvisibilityautostatechange, oncontextlost, oncontextmenu, oncontextrestored, oncuechange, ondblclick, ondevicemotion, ondeviceorientation, ondeviceorientationabsolute, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended, onerror, onfocus, onformdata, ongotpointercapture, onhashchange, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onlanguagechange, onload, onloadeddata, onloadedmetadata, onloadstart, onlostpointercapture, onmessage, onmessageerror, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onoffline, ononline, onpagehide, onpagereveal, onpageshow, onpageswap, onpause, onplay, onplaying, onpointercancel, onpointerdown, onpointerenter, onpointerleave, onpointermove, onpointerout, onpointerover, onpointerrawupdate, onpointerup, onpopstate, onprogress, onratechange, onrejectionhandled, onreset, onresize, onscroll, onscrollend, onscrollsnapchange, onscrollsnapchanging, onsearch, onsecuritypolicyviolation, onseeked, onseeking, onselect, onselectionchange, onselectstart, onslotchange, onstalled, onstorage, onsubmit, onsuspend, ontimeupdate, ontoggle, ontransitioncancel, ontransitionend, ontransitionrun, ontransitionstart, onunhandledrejection, onunload, onvolumechange, onwaiting, onwebkitanimationend, onwebkitanimationiteration, onwebkitanimationstart, onwebkittransitionend, onwheel, open, opener, Option, OrientationSensor, origin, originAgentCluster, OscillatorNode, OTPCredential, outerHeight, outerWidth, OverconstrainedError, PageRevealEvent, PageSwapEvent, PageTransitionEvent, pageXOffset, pageYOffset, PannerNode, parent, PasswordCredential, Path2D, PaymentAddress, PaymentManager, PaymentMethodChangeEvent, PaymentRequest, PaymentRequestUpdateEvent, PaymentResponse, performance, Performance, PerformanceElementTiming, PerformanceEntry, PerformanceEventTiming, PerformanceLongAnimationFrameTiming, PerformanceLongTaskTiming, PerformanceMark, PerformanceMeasure, PerformanceNavigation, PerformanceNavigationTiming, PerformanceObserver, PerformanceObserverEntryList, PerformancePaintTiming, PerformanceResourceTiming, PerformanceScriptTiming, PerformanceServerTiming, PerformanceTiming, PeriodicSyncManager, PeriodicWave, Permissions, PermissionStatus, personalbar, PictureInPictureEvent, PictureInPictureWindow, Plugin, PluginArray, PointerEvent, PopStateEvent, postMessage, Presentation, PresentationAvailability, PresentationConnection, PresentationConnectionAvailableEvent, PresentationConnectionCloseEvent, PresentationConnectionList, PresentationReceiver, PresentationRequest, PressureObserver, PressureRecord, print, ProcessingInstruction, Profiler, ProgressEvent, PromiseRejectionEvent, prompt, ProtectedAudience, PublicKeyCredential, PushManager, PushSubscription, PushSubscriptionOptions, queryLocalFonts, queueMicrotask, RadioNodeList, Range, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, RelativeOrientationSensor, releaseEvents, RemotePlayback, ReportBody, reportError, ReportingObserver, Request, requestAnimationFrame, requestIdleCallback, resizeBy, ResizeObserver, ResizeObserverEntry, ResizeObserverSize, resizeTo, Response, RestrictionTarget, RTCCertificate, RTCDataChannel, RTCDataChannelEvent, RTCDtlsTransport, RTCDTMFSender, RTCDTMFToneChangeEvent, RTCEncodedAudioFrame, RTCEncodedVideoFrame, RTCError, RTCErrorEvent, RTCIceCandidate, RTCIceTransport, RTCPeerConnection, RTCPeerConnectionIceErrorEvent, RTCPeerConnectionIceEvent, RTCRtpReceiver, RTCRtpSender, RTCRtpTransceiver, RTCSctpTransport, RTCSessionDescription, RTCStatsReport, RTCTrackEvent, scheduler, Scheduler, Scheduling, screen, Screen, ScreenDetailed, ScreenDetails, screenLeft, ScreenOrientation, screenTop, screenX, screenY, ScriptProcessorNode, scroll, scrollbars, scrollBy, ScrollTimeline, scrollTo, scrollX, scrollY, SecurityPolicyViolationEvent, Selection, self, Sensor, SensorErrorEvent, Serial, SerialPort, ServiceWorker, ServiceWorkerContainer, ServiceWorkerRegistration, sessionStorage, setInterval, setTimeout, ShadowRoot, SharedArrayBuffer, sharedStorage, SharedStorage, SharedStorageAppendMethod, SharedStorageClearMethod, SharedStorageDeleteMethod, SharedStorageModifierMethod, SharedStorageSetMethod, SharedStorageWorklet, SharedWorker, showDirectoryPicker, showOpenFilePicker, showSaveFilePicker, SnapEvent, SourceBuffer, SourceBufferList, speechSynthesis, SpeechSynthesis, SpeechSynthesisErrorEvent, SpeechSynthesisEvent, SpeechSynthesisUtterance, SpeechSynthesisVoice, StaticRange, status, statusbar, StereoPannerNode, stop, Storage, StorageBucket, StorageBucketManager, StorageEvent, StorageManager, structuredClone, styleMedia, StylePropertyMap, StylePropertyMapReadOnly, StyleSheet, StyleSheetList, SubmitEvent, Subscriber, SubtleCrypto, SuppressedError, SVGAElement, SVGAngle, SVGAnimatedAngle, SVGAnimatedBoolean, SVGAnimatedEnumeration, SVGAnimatedInteger, SVGAnimatedLength, SVGAnimatedLengthList, SVGAnimatedNumber, SVGAnimatedNumberList, SVGAnimatedPreserveAspectRatio, SVGAnimatedRect, SVGAnimatedString, SVGAnimatedTransformList, SVGAnimateElement, SVGAnimateMotionElement, SVGAnimateTransformElement, SVGAnimationElement, SVGCircleElement, SVGClipPathElement, SVGComponentTransferFunctionElement, SVGDefsElement, SVGDescElement, SVGElement, SVGEllipseElement, SVGFEBlendElement, SVGFEColorMatrixElement, SVGFEComponentTransferElement, SVGFECompositeElement, SVGFEConvolveMatrixElement, SVGFEDiffuseLightingElement, SVGFEDisplacementMapElement, SVGFEDistantLightElement, SVGFEDropShadowElement, SVGFEFloodElement, SVGFEFuncAElement, SVGFEFuncBElement, SVGFEFuncGElement, SVGFEFuncRElement, SVGFEGaussianBlurElement, SVGFEImageElement, SVGFEMergeElement, SVGFEMergeNodeElement, SVGFEMorphologyElement, SVGFEOffsetElement, SVGFEPointLightElement, SVGFESpecularLightingElement, SVGFESpotLightElement, SVGFETileElement, SVGFETurbulenceElement, SVGFilterElement, SVGForeignObjectElement, SVGGElement, SVGGeometryElement, SVGGradientElement, SVGGraphicsElement, SVGImageElement, SVGLength, SVGLengthList, SVGLinearGradientElement, SVGLineElement, SVGMarkerElement, SVGMaskElement, SVGMatrix, SVGMetadataElement, SVGMPathElement, SVGNumber, SVGNumberList, SVGPathElement, SVGPatternElement, SVGPoint, SVGPointList, SVGPolygonElement, SVGPolylineElement, SVGPreserveAspectRatio, SVGRadialGradientElement, SVGRect, SVGRectElement, SVGScriptElement, SVGSetElement, SVGStopElement, SVGStringList, SVGStyleElement, SVGSVGElement, SVGSwitchElement, SVGSymbolElement, SVGTextContentElement, SVGTextElement, SVGTextPathElement, SVGTextPositioningElement, SVGTitleElement, SVGTransform, SVGTransformList, SVGTSpanElement, SVGUnitTypes, SVGUseElement, SVGViewElement, SyncManager, TaskAttributionTiming, TaskController, TaskPriorityChangeEvent, TaskSignal, Text, TextDecoder, TextDecoderStream, TextEncoder, TextEncoderStream, TextEvent, TextFormat, TextFormatUpdateEvent, TextMetrics, TextTrack, TextTrackCue, TextTrackCueList, TextTrackList, TextUpdateEvent, TimeRanges, ToggleEvent, toolbar, top, Touch, TouchEvent, TouchList, TrackEvent, TransformStream, TransformStreamDefaultController, TransitionEvent, TreeWalker, TrustedHTML, TrustedScript, TrustedScriptURL, TrustedTypePolicy, TrustedTypePolicyFactory, trustedTypes, UIEvent, URL, URLPattern, URLSearchParams, USB, USBAlternateInterface, USBConfiguration, USBConnectionEvent, USBDevice, USBEndpoint, USBInterface, USBInTransferResult, USBIsochronousInTransferPacket, USBIsochronousInTransferResult, USBIsochronousOutTransferPacket, USBIsochronousOutTransferResult, USBOutTransferResult, UserActivation, ValidityState, VideoColorSpace, VideoDecoder, VideoEncoder, VideoFrame, VideoPlaybackQuality, ViewTimeline, ViewTransition, ViewTransitionTypeSet, VirtualKeyboard, VirtualKeyboardGeometryChangeEvent, VisibilityStateEntry, visualViewport, VisualViewport, VTTCue, WakeLock, WakeLockSentinel, WaveShaperNode, WebAssembly, WebGL2RenderingContext, WebGLActiveInfo, WebGLBuffer, WebGLContextEvent, WebGLFramebuffer, WebGLObject, WebGLProgram, WebGLQuery, WebGLRenderbuffer, WebGLRenderingContext, WebGLSampler, WebGLShader, WebGLShaderPrecisionFormat, WebGLSync, WebGLTexture, WebGLTransformFeedback, WebGLUniformLocation, WebGLVertexArrayObject, webkitCancelAnimationFrame, WebKitCSSMatrix, webkitMediaStream, WebKitMutationObserver, webkitRequestAnimationFrame, webkitRequestFileSystem, webkitResolveLocalFileSystemURL, webkitRTCPeerConnection, webkitSpeechGrammar, webkitSpeechGrammarList, webkitSpeechRecognition, webkitSpeechRecognitionError, webkitSpeechRecognitionEvent, webkitURL, WebSocket, WebSocketError, WebSocketStream, WebTransport, WebTransportBidirectionalStream, WebTransportDatagramDuplexStream, WebTransportError, WGSLLanguageFeatures, WheelEvent, window, Window, WindowControlsOverlay, WindowControlsOverlayGeometryChangeEvent, Worker, Worklet, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, XMLDocument, XMLHttpRequest, XMLHttpRequestEventTarget, XMLHttpRequestUpload, XMLSerializer, XPathEvaluator, XPathExpression, XPathResult, XRAnchor, XRAnchorSet, XRBoundedReferenceSpace, XRCamera, XRCPUDepthInformation, XRDepthInformation, XRDOMOverlayState, XRFrame, XRHand, XRHitTestResult, XRHitTestSource, XRInputSource, XRInputSourceArray, XRInputSourceEvent, XRInputSourcesChangeEvent, XRJointPose, XRJointSpace, XRLayer, XRLightEstimate, XRLightProbe, XRPose, XRRay, XRReferenceSpace, XRReferenceSpaceEvent, XRRenderState, XRRigidTransform, XRSession, XRSessionEvent, XRSpace, XRSystem, XRTransientInputHitTestResult, XRTransientInputHitTestSource, XRView, XRViewerPose, XRViewport, XRWebGLBinding, XRWebGLDepthInformation, XRWebGLLayer, XSLTProcessor
|
|
21
|
+
- "GlobalThisValue" is the Global Object defined in the ECMAScript specification.
|
|
22
|
+
- For review purposes, a "GlobalThisValue" is any of the following: `window`, `window.top`, `window.parent`, `window.frames`, `globalThis`, `self` (when `self` is at the top level of the global scope), or `this` (when `this` is at the top level of the global scope or in `eval()`).
|
|
23
|
+
- `document` is not a "GlobalThisValue", but the value of `defaultView` property is a "GlobalThisValue".
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Block Document CreateProcessingInstruction Analysis
|
|
28
|
+
|
|
29
|
+
## Code Review: Identify and Block document.createProcessingInstruction usage.
|
|
30
|
+
|
|
31
|
+
### My Job
|
|
32
|
+
|
|
33
|
+
I identify ALL usage of document.createProcessingInstruction. This API introduces XML injection and XSS vulnerabilities.
|
|
34
|
+
|
|
35
|
+
### What I Look For
|
|
36
|
+
|
|
37
|
+
Calls to document.createProcessingInstruction in all contexts: Loops, conditionals, event handlers, async callbacks, template literals, string concatenation, hidden by unicode escape sequences and Reflection APIs.
|
|
38
|
+
|
|
39
|
+
### Why It's Critical
|
|
40
|
+
|
|
41
|
+
Creates XML injection vulnerabilities enabling XSS attacks through stylesheet injection, data URIs, and CSP bypass.
|
|
42
|
+
|
|
43
|
+
### Safe Alternative
|
|
44
|
+
|
|
45
|
+
Remove the dangerous code. If stylesheet loading is needed, use `document.createElement('link')` and append to `document.head` in JavaScript. Do not add `<link>` to any refactored markup (not allowed).
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
# Block Document Event Handler Analysis
|
|
50
|
+
|
|
51
|
+
## Code Review: Identify and Block forbidden document event handler usage.
|
|
52
|
+
|
|
53
|
+
### Rule
|
|
54
|
+
|
|
55
|
+
Flag ONLY actual event handler registrations for these THREE forbidden events:
|
|
56
|
+
|
|
57
|
+
- rejectionhandled
|
|
58
|
+
- securitypolicyviolation
|
|
59
|
+
- unhandledrejection
|
|
60
|
+
|
|
61
|
+
### Correct Usage
|
|
62
|
+
|
|
63
|
+
1. Remove all forbidden event handlers.
|
|
64
|
+
2. Handle errors and rejections locally within the component scope.
|
|
65
|
+
|
|
66
|
+
### Instructions
|
|
67
|
+
|
|
68
|
+
1. Scan EVERY line for these patterns
|
|
69
|
+
2. All contexts: Loops, conditionals, event handlers, async callbacks, template literals, string concatenation, hidden by unicode escape sequences
|
|
70
|
+
3. Case-sensitive matching
|
|
71
|
+
4. Flag EVERY occurrence - no exceptions
|
|
72
|
+
5. Include the complete code context
|
|
73
|
+
6. Report ALL violations found
|
|
74
|
+
|
|
75
|
+
### Constraints
|
|
76
|
+
|
|
77
|
+
1. **Preserve Logic**: Maintain all other code logic. Do not remove any code that is not related to the forbidden event handlers.
|
|
78
|
+
2. **Complete Coverage**: Flag ALL instances of forbidden event handlers.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
# Block Document Open
|
|
83
|
+
|
|
84
|
+
## Code Review: Identify and Block critical security issues with document.open usage.
|
|
85
|
+
|
|
86
|
+
### My Job
|
|
87
|
+
|
|
88
|
+
I examine JavaScript and TypeScript code to find ALL instances of `document.open` called with zero, one, or two arguments. These methods are inherently dangerous and represent critical security vulnerabilities that must be removed.
|
|
89
|
+
|
|
90
|
+
### What I Flag
|
|
91
|
+
|
|
92
|
+
- `document.open()` with 0 args: BLOCKED - Clears document (security risk)
|
|
93
|
+
- `document.open(url)` with 1 arg: BLOCKED - Opens in same window (navigation hijacking)
|
|
94
|
+
- `document.open(url, name)` with 2 args: BLOCKED - Opens with target in same window (security risk)
|
|
95
|
+
- `document.open(url, name, features)` with 3+ args: ALLOWED
|
|
96
|
+
|
|
97
|
+
I detect direct calls, bracket notation (`document['open']`), destructuring (`const {open} = document`), and variable references in all contexts: Loops, conditionals, event handlers, async callbacks, template literals, string concatenation, hidden by unicode escape sequencesl
|
|
98
|
+
|
|
99
|
+
### Fix Recommendations
|
|
100
|
+
|
|
101
|
+
Replace with:
|
|
102
|
+
|
|
103
|
+
- `window.open(url, "_blank", "noopener,noreferrer")` for new windows
|
|
104
|
+
- DOM APIs (`createElement`, `appendChild`) for content manipulation
|
|
105
|
+
- Navigation APIs for routing
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
# Block Document Write
|
|
110
|
+
|
|
111
|
+
## Code Review: Identify and Block unsafe document.write and document.writeln usage.
|
|
112
|
+
|
|
113
|
+
### My Job
|
|
114
|
+
|
|
115
|
+
I examine JavaScript and TypeScript code to find ALL instances of `document.write` and `document.writeln`. These methods are inherently dangerous and represent critical security vulnerabilities that must be removed.
|
|
116
|
+
|
|
117
|
+
### What I Flag
|
|
118
|
+
|
|
119
|
+
- **document.write()**: ALL uses - allows HTML injection enabling XSS attacks
|
|
120
|
+
- **document.writeln()**: ALL uses - identical to document.write with newline
|
|
121
|
+
- **Indirect calls**: Bracket notation (`document['write']`), destructuring (`const {write} = document`), aliasing
|
|
122
|
+
- **All contexts**: Loops, conditionals, event handlers, async callbacks, template literals, string concatenation, hidden by unicode escape sequences and Reflection APIs.
|
|
123
|
+
|
|
124
|
+
### Why Critical
|
|
125
|
+
|
|
126
|
+
These methods enable XSS attacks, can replace entire page content, block parsing, and violate LWS security policies. NO safe usage exists.
|
|
127
|
+
|
|
128
|
+
### Safe Alternatives
|
|
129
|
+
|
|
130
|
+
Use DOM APIs (`createElement`, `appendChild`), LWC templates, or `textContent` for user data.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
# Block Direct Script Element Creation Analysis
|
|
135
|
+
|
|
136
|
+
## Code Review: Identify and Block direct script element creation.
|
|
137
|
+
|
|
138
|
+
### My Job
|
|
139
|
+
|
|
140
|
+
I detect direct script element creation and manipulation that could enable XSS attacks or CSP bypasses.
|
|
141
|
+
|
|
142
|
+
### What I Look For
|
|
143
|
+
|
|
144
|
+
- `document.createElement('script')` or `new HTMLScriptElement()`
|
|
145
|
+
- Script injection via innerHTML/outerHTML/insertAdjacentHTML
|
|
146
|
+
- Setting script.src to dynamic/untrusted URLs, blob URLs, or data URLs
|
|
147
|
+
- Setting script.textContent, script.text, or script.innerHTML with code
|
|
148
|
+
- All contexts: Loops, conditionals, event handlers, async callbacks, template literals, string concatenation, hidden by unicode escape sequences
|
|
149
|
+
|
|
150
|
+
### Secure Alternative for Lightning Web Components
|
|
151
|
+
|
|
152
|
+
If the code contains a class that extends `LightningElement`, recommend using the platform's `loadScript` utility from `lightning/platformResourceLoader`.
|
|
153
|
+
|
|
154
|
+
### Examples
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
// VIOLATION: Direct creation
|
|
158
|
+
const script = document.createElement('script');
|
|
159
|
+
script.src = untrustedUrl;
|
|
160
|
+
|
|
161
|
+
// VIOLATION: Setting textContent
|
|
162
|
+
script.textContent = userInput;
|
|
163
|
+
|
|
164
|
+
// VIOLATION: innerHTML injection
|
|
165
|
+
element.innerHTML = '<script>alert(1)</script>';
|
|
166
|
+
|
|
167
|
+
// VIOLATION: Blob URL
|
|
168
|
+
script.src = URL.createObjectURL(blob);
|
|
169
|
+
|
|
170
|
+
// SECURE (for Lightning Web Components): Use loadScript
|
|
171
|
+
import { loadScript } from 'lightning/platformResourceLoader';
|
|
172
|
+
await loadScript(this, LIBRARY_URL);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
# Block eval
|
|
178
|
+
|
|
179
|
+
## Code Review: Identify and Block eval, Function, new Function and setInterval or setTimeout with a string.
|
|
180
|
+
|
|
181
|
+
### My Job
|
|
182
|
+
|
|
183
|
+
I examine Lightning Web Components and/or any JavaScript code to find all instances of eval, setInterval, setTimeout, Function, and new Function usage that represent critical security vulnerabilities.
|
|
184
|
+
|
|
185
|
+
### What I Look For
|
|
186
|
+
|
|
187
|
+
- **eval**: Any code sent to JavaScript eval function is unsafe, and should be avoided.
|
|
188
|
+
- **setInterval**: Any code evaluated via string argument is unsafe, and should be avoided.
|
|
189
|
+
- **setTimeout**: Any code evaluated via string argument is unsafe, and should be avoided.
|
|
190
|
+
- **Function**: Any code evaluated via string argument is unsafe, and should be avoided.
|
|
191
|
+
- **new Function**: Any code evaluated via string argument is unsafe, and should be avoided.
|
|
192
|
+
|
|
193
|
+
### Correct Usage
|
|
194
|
+
|
|
195
|
+
1. Occurrences of eval, Function, and new Function must be annotated with a comment warning against use.
|
|
196
|
+
2. Occurrences of setInterval, setTimeout that accept a string argument should be removed.
|
|
197
|
+
|
|
198
|
+
### Review Steps
|
|
199
|
+
|
|
200
|
+
1. **Identify Usage**: I check for occurrences of eval, setInterval, setTimeout, Function, and new Function in the code.
|
|
201
|
+
2. **Evaluate Safety**: I determine if usage is unsafe for LWS, according to the criteria above.
|
|
202
|
+
|
|
203
|
+
### Constraints
|
|
204
|
+
|
|
205
|
+
1. **Preserve Logic**: I maintain all other code logic. I do not remove any code that is not related to the issue.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
# Block Event Properties
|
|
210
|
+
|
|
211
|
+
## Code Review: Identify and Block all event.originalTarget and event.explicitOriginalTarget usages.
|
|
212
|
+
|
|
213
|
+
### My Job
|
|
214
|
+
|
|
215
|
+
I examine JavaScript and TypeScript code to find ALL instances of forbidden event properties. I MUST report EVERY SINGLE occurrence of `event.originalTarget` and `event.explicitOriginalTarget`.
|
|
216
|
+
|
|
217
|
+
### What I Look For
|
|
218
|
+
|
|
219
|
+
**Forbidden Event Properties** (always flag):
|
|
220
|
+
|
|
221
|
+
- `event.originalTarget`
|
|
222
|
+
- `event.explicitOriginalTarget`
|
|
223
|
+
- `Event.prototype.originalTarget`
|
|
224
|
+
- `Event.prototype.explicitOriginalTarget`
|
|
225
|
+
|
|
226
|
+
### Why This Matters
|
|
227
|
+
|
|
228
|
+
These properties bypass Lightning Web Security's shadow DOM isolation and expose elements outside the component's security boundary.
|
|
229
|
+
|
|
230
|
+
### Review Steps
|
|
231
|
+
|
|
232
|
+
1. **Scan for direct access**: Find all `event.originalTarget` and `event.explicitOriginalTarget` usage
|
|
233
|
+
2. **Check prototype modifications**: Find modifications to Event.prototype
|
|
234
|
+
3. **Flag all instances**: Every occurrence is a violation
|
|
235
|
+
|
|
236
|
+
### Output Format
|
|
237
|
+
|
|
238
|
+
For each issue I find:
|
|
239
|
+
|
|
240
|
+
- **Suggested Action**: Use `event.target` or `event.currentTarget` instead
|
|
241
|
+
|
|
242
|
+
### Constraints
|
|
243
|
+
|
|
244
|
+
1. **Complete coverage**: Return EVERY instance found in the code
|
|
245
|
+
|
|
246
|
+
### Important Notes
|
|
247
|
+
|
|
248
|
+
- There are NO exceptions for these forbidden properties
|
|
249
|
+
- ALL instances must be flagged regardless of context
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
# Block Fullscreen API
|
|
254
|
+
|
|
255
|
+
## Code Review: Identify and Block requestFullscreen and vendor prefixed versions usage.
|
|
256
|
+
|
|
257
|
+
### My Job
|
|
258
|
+
|
|
259
|
+
I examine Lightning Web Components and/or any JavaScript or TypeScript code to find all instances of requestFullscreen() method invocations. Only requestFullscreen and its vendor-prefixed variants are violations.
|
|
260
|
+
|
|
261
|
+
### What I Look For
|
|
262
|
+
|
|
263
|
+
#### Critical Security Issues - Fullscreen API Invocations
|
|
264
|
+
|
|
265
|
+
**Methods** (always flag):
|
|
266
|
+
|
|
267
|
+
- `requestFullscreen()` - Standard method
|
|
268
|
+
- `webkitRequestFullscreen()` - WebKit prefix
|
|
269
|
+
- `mozRequestFullScreen()` - Mozilla prefix (capital 'S' in 'Screen')
|
|
270
|
+
- `msRequestFullscreen()` - Microsoft prefix
|
|
271
|
+
|
|
272
|
+
### Key Considerations
|
|
273
|
+
|
|
274
|
+
- **Fullscreen API**: Any usage of Fullscreen API method - requestFullscreen as well as vendor prefixed versions - is unsafe and can be exploited for phishing attacks by hiding browser security indicators.
|
|
275
|
+
- **All variants**: This includes all browser-prefixed versions (webkit, moz) and all access patterns (direct, dynamic, stored references).
|
|
276
|
+
- **Case sensitivity**: Pay special attention to mozRequestFullScreen (capital 'S' in 'Screen') vs other variants.
|
|
277
|
+
- **String property access**: Pay special attention to string properties that contain the word 'fullscreen' as well as the word 'screen', it can act as a backdoor entry point for phishing attacks.
|
|
278
|
+
|
|
279
|
+
### Correct Usage
|
|
280
|
+
|
|
281
|
+
1. Remove all requestFullscreen and vendor prefixed versions usage from Lightning Web Components and/or any JavaScript code.
|
|
282
|
+
2. Do not implement fullscreen functionality due to security risks.
|
|
283
|
+
|
|
284
|
+
### Review Steps
|
|
285
|
+
|
|
286
|
+
1. All occurrences of requestFullscreen is a violation.
|
|
287
|
+
|
|
288
|
+
### Constraints
|
|
289
|
+
|
|
290
|
+
1. **Preserve Logic**: Maintain all other code logic. Do not remove any code that is not related to the requestFullscreen and vendor prefixed versions.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
# Block Global Object Property Assignment Analysis
|
|
295
|
+
|
|
296
|
+
## Code Review: Identify and Block all direct property assignments to global objects.
|
|
297
|
+
|
|
298
|
+
**CRITICAL PREREQUISITE:**
|
|
299
|
+
|
|
300
|
+
- ONLY analyze files that import from 'lwc'
|
|
301
|
+
- If a file does NOT import from 'lwc', DO NOT flag ANY issues in that file
|
|
302
|
+
- **IMPORTANT:** If a file has NO import statements at all, it should be skipped entirely
|
|
303
|
+
- **WARNING:** Even if you find obvious GlobalThisValue assignments like `globalThis.property = value`, you MUST ignore them if there's no LightningElement import
|
|
304
|
+
- This rule applies to the ENTIRE file - if no LightningElement import, skip the file entirely
|
|
305
|
+
|
|
306
|
+
### Review Steps
|
|
307
|
+
|
|
308
|
+
1. **STEP 1 - Import Check (MANDATORY):**
|
|
309
|
+
|
|
310
|
+
- Search the entire file for any import declarations whose with clause is 'lwc'
|
|
311
|
+
|
|
312
|
+
**DECISION POINT:**
|
|
313
|
+
|
|
314
|
+
- If an import is found → Continue to Step 2
|
|
315
|
+
- If NO import declaration whose with clause is 'lwc' are found → Return empty list (no issues). DO NOT CONTINUE TO STEP 2.
|
|
316
|
+
|
|
317
|
+
2. **STEP 2 - Global Object Analysis (only if Step 1 passed):**
|
|
318
|
+
|
|
319
|
+
- Find all JavaScript code that directly assigns properties to global objects. Look for patterns like:
|
|
320
|
+
- `globalThis.propertyName = value`
|
|
321
|
+
- `window.propertyName = value`
|
|
322
|
+
- `window.top.propertyName = value`
|
|
323
|
+
- `window.parent.propertyName = value`
|
|
324
|
+
- `window.frames.propertyName = value`
|
|
325
|
+
- `document.defaultView.propertyName = value`
|
|
326
|
+
- `self.propertyName = value` (when self refers to the global object)
|
|
327
|
+
- `this.propertyName = value` (when this refers to the global object in global scope, or at the top level)
|
|
328
|
+
|
|
329
|
+
3. Do NOT flag:
|
|
330
|
+
|
|
331
|
+
- Property access (reading): `const x = window.location`
|
|
332
|
+
- Local assignments: `function foo(window) { window.localVar = 1 }`
|
|
333
|
+
- Method calls: `window.alert('hello')`
|
|
334
|
+
- Host objects (like document etc.) EXCEPT when they are used as global object references
|
|
335
|
+
|
|
336
|
+
4. IMPORTANT:
|
|
337
|
+
|
|
338
|
+
- NEVER flag Built-in objects (like Set, Map, Array, etc.)
|
|
339
|
+
- NEVER flag Host objects (like document etc.) EXCEPT when they are used as global object references
|
|
340
|
+
- Global object references that should be flagged: globalThis, window, window.top, window.parent, window.frames, document.defaultView, self (global), this (global)
|
|
341
|
+
|
|
342
|
+
### Examples
|
|
343
|
+
|
|
344
|
+
**Examples of what to FLAG:**
|
|
345
|
+
|
|
346
|
+
```javascript
|
|
347
|
+
globalThis.myVar = 'hello';
|
|
348
|
+
window.config = { debug: true };
|
|
349
|
+
window.top.config = { debug: true };
|
|
350
|
+
window.parent.config = { debug: true };
|
|
351
|
+
window.frames.config = { debug: true };
|
|
352
|
+
self.data = [];
|
|
353
|
+
this.globalFunction = function () {};
|
|
354
|
+
document.defaultView.property = value;
|
|
355
|
+
globalThis.foo += 1;
|
|
356
|
+
window.bar -= 5;
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**Examples of what to IGNORE:**
|
|
360
|
+
|
|
361
|
+
```javascript
|
|
362
|
+
const x = window.location; // reading, not assigning
|
|
363
|
+
function foo(window) {
|
|
364
|
+
window.local = 1;
|
|
365
|
+
} // local parameter
|
|
366
|
+
window.alert('hello'); // method call, not assignment
|
|
367
|
+
const config = window.config; // reading
|
|
368
|
+
document.cookie = 'foo=bar'; // DO NOT FLAG - document is not in the flagged list
|
|
369
|
+
localStorage.setItem('key', 'value'); // DO NOT FLAG - localStorage is not in the flagged list
|
|
370
|
+
document.foo = 1; // DO NOT FLAG - document is not in the flagged list
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
When reviewing code, include ALL VIOLATIONS. Do not omit any.
|
|
374
|
+
|
|
375
|
+
### Constraints
|
|
376
|
+
|
|
377
|
+
1. **LightningElement Import Required**: Only analyze files that import LightningElement
|
|
378
|
+
2. **Preserve Logic**: Maintain all other code logic.
|
|
379
|
+
3. ONLY report issues that are related to the instructions.
|
|
380
|
+
4. Properties of other objects are not considered "global objects" references.
|
|
381
|
+
5. Violations of the rules are considered security issues.
|
|
382
|
+
|
|
383
|
+
### Final Validation
|
|
384
|
+
|
|
385
|
+
Before returning any issues, ask yourself:
|
|
386
|
+
|
|
387
|
+
1. Does this file import LightningElement? (Check for import statements)
|
|
388
|
+
2. If NO → Return empty list
|
|
389
|
+
3. If YES → Return the issues found
|
|
390
|
+
|
|
391
|
+
**Remember:** No LightningElement import = No issues to report, regardless of what global object assignments you find.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
# Block HTML Body Element Event Analysis
|
|
396
|
+
|
|
397
|
+
## Code Review: Identify and Block use of document.body event handlers that leak sensitive information
|
|
398
|
+
|
|
399
|
+
### My Job
|
|
400
|
+
|
|
401
|
+
I find document.body event handler usage that creates security vulnerabilities by exposing promise rejections, storage events, navigation state, and enabling user tracking.
|
|
402
|
+
|
|
403
|
+
### What I Detect
|
|
404
|
+
|
|
405
|
+
- `document.body.addEventListener(...)` and `document.body.oneventname = ...` assignments
|
|
406
|
+
- Destructured references: `const { body } = document;` then `body.addEventListener` or `body.oneventname`
|
|
407
|
+
- Bracket notation: `document.body['on' + var]` or `body[eventName]`
|
|
408
|
+
- Unicode escapes: `document.body['\u006f\u006e...']`
|
|
409
|
+
- Reflect patterns: `Reflect.set(document.body, 'onevent', ...)` or `Reflect.apply(document.body.addEventListener, ...)`
|
|
410
|
+
- String concatenation for event names
|
|
411
|
+
|
|
412
|
+
### What I Report
|
|
413
|
+
|
|
414
|
+
I flag only the **actual handler assignment line**, not intermediate variable construction. I report ALL occurrences case-sensitively.
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
# Block Nonce Access Analysis
|
|
419
|
+
|
|
420
|
+
## Code Review: Identify and Block nonce value access violations (CSP enforcement)
|
|
421
|
+
|
|
422
|
+
### My Job
|
|
423
|
+
|
|
424
|
+
I identify ALL attempts to access nonce values on HTMLElement/SVGElement objects. Nonce access enables CSP bypass attacks.
|
|
425
|
+
|
|
426
|
+
### Core Rule
|
|
427
|
+
|
|
428
|
+
Nonces are cryptographic tokens for Content-Security-Policy and must NEVER be readable from client-side JavaScript.
|
|
429
|
+
|
|
430
|
+
### What I Look For
|
|
431
|
+
|
|
432
|
+
- **Direct access**: `element.nonce`, `element['nonce']`
|
|
433
|
+
- **getAttribute methods**: `.getAttribute('nonce')`, `.getAttributeNode('nonce')`
|
|
434
|
+
- **Selectors**: `querySelector('[nonce]')`, `querySelectorAll('script[nonce]')`
|
|
435
|
+
- **Variable-based**: `element[prop]`, `getAttribute(attrName)`, string concat/templates
|
|
436
|
+
- **Storage**: `localStorage/sessionStorage.setItem()` with nonce values
|
|
437
|
+
- **Setting**: `element.nonce = value`, `setAttribute('nonce', value)`
|
|
438
|
+
- **Loops**: `forEach`, `map`, `for...of` accessing nonce
|
|
439
|
+
- **Destructuring**: `const { nonce } = element`
|
|
440
|
+
- **Conditionals**: `if (element.nonce)`, `element.nonce || default`
|
|
441
|
+
|
|
442
|
+
### Why It Matters
|
|
443
|
+
|
|
444
|
+
Stolen nonces allow attackers to inject unauthorized scripts that bypass CSP, enabling XSS attacks.
|
|
445
|
+
|
|
446
|
+
### Correct Approach
|
|
447
|
+
|
|
448
|
+
If the code contains a class that extends `LightningElement`, use `loadScript`/`loadStyle` from `lightning/platformResourceLoader`. Never access, store, or transmit nonce values.
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
# Block UIEvent Range Parent Analysis
|
|
453
|
+
|
|
454
|
+
## Code Review: Identify and Block UIEvent Range Parent Access
|
|
455
|
+
|
|
456
|
+
### My Job
|
|
457
|
+
|
|
458
|
+
I find all instances where code accesses the `rangeParent` property from event objects. This includes direct access (event.rangeParent), chained access (event.target.rangeParent), destructuring, and obfuscated patterns using unicode escapes, bracket notation, or Reflect APIs.
|
|
459
|
+
|
|
460
|
+
### Fix
|
|
461
|
+
|
|
462
|
+
Replace with event.target or event.currentTarget instead.
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
# Block XSLTProcessor Analysis
|
|
467
|
+
|
|
468
|
+
## Code Review: Identify and Block all XSLTProcessor API usage.
|
|
469
|
+
|
|
470
|
+
### My Job
|
|
471
|
+
|
|
472
|
+
I find ALL instances of `XSLTProcessor`, `transformToFragment`, and `transformToDocument`. These APIs enable XSS attacks and bypass security controls.
|
|
473
|
+
|
|
474
|
+
### What I Look For
|
|
475
|
+
|
|
476
|
+
- `new XSLTProcessor()` - direct instantiation
|
|
477
|
+
- `window.XSLTProcessor` or `const P = XSLTProcessor` - indirect references
|
|
478
|
+
- `Reflect.construct(XSLTProcessor, [])` - reflection-based instantiation
|
|
479
|
+
- `transformToFragment()` and `transformToDocument()` - transformation methods
|
|
480
|
+
- `processor['transformToFragment']` - bracket notation
|
|
481
|
+
- `Reflect.apply()`, `.apply()`, `.call()`, `.bind()` - reflection-based method calls
|
|
482
|
+
|
|
483
|
+
### Why This Matters
|
|
484
|
+
|
|
485
|
+
XSLT transformations can generate `<script>` tags, event handlers, and bypass CSP. There is NO safe usage.
|
|
486
|
+
|
|
487
|
+
### Safe Alternatives
|
|
488
|
+
|
|
489
|
+
1. If the code contains a class that extends `LightningElement`, use LWC templates with data binding
|
|
490
|
+
2. Process XML on server-side with Apex
|
|
491
|
+
3. Use JSON instead of XML
|
|
492
|
+
4. Use DOM APIs (`createElement`, `appendChild`) with proper escaping
|
|
493
|
+
|
|
494
|
+
### Output Format
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
# Block Context Vulnerability Access Analysis
|
|
499
|
+
|
|
500
|
+
## Code Review: Identify and Block context vulnerability attacks.
|
|
501
|
+
|
|
502
|
+
### My Job
|
|
503
|
+
|
|
504
|
+
I identify security vulnerabilities where **imported framework classes** are exploited through context manipulation: bind(), call(), apply(), Reflect methods, prototype manipulation, and framework element access.
|
|
505
|
+
|
|
506
|
+
**CRITICAL**: Imported modules expose framework internals. Static resources via loadScript() are safe.
|
|
507
|
+
|
|
508
|
+
### What I Look For
|
|
509
|
+
|
|
510
|
+
1. **Method Context Manipulation**: .call(), .apply(), .bind(), Reflect.apply() on imported methods with external context
|
|
511
|
+
2. **Crafted Fake Context**: Objects mimicking framework structures passed to framework methods
|
|
512
|
+
3. **Component Extension**: Extending imported framework components to access inherited internals
|
|
513
|
+
4. **Prototype Manipulation**: **lookupSetter**(), **lookupGetter**(), Object.getPrototypeOf(), Object.setPrototypeOf()
|
|
514
|
+
5. **Internal Property Access**: .helper, .context, .owner, .navService on DOM elements/components
|
|
515
|
+
6. **Hierarchy Traversal**: getOwner(), getContext() calls or loops traversing object hierarchies
|
|
516
|
+
7. **Dynamic Creation with Exploited Context**: Using stolen contexts for component creation
|
|
517
|
+
8. **Complex Invocation Chains**: Function.prototype.call.apply() or Function.prototype.apply.call()
|
|
518
|
+
9. **All contexts**: Loops, conditionals, event handlers, async callbacks, template literals, string concatenation, hidden by unicode escape sequences
|
|
519
|
+
|
|
520
|
+
### What I Ignore
|
|
521
|
+
|
|
522
|
+
- Standard LWC lifecycle methods
|
|
523
|
+
- Event handlers with proper this binding within same component
|
|
524
|
+
- Built-in JavaScript methods without external context manipulation
|
|
525
|
+
- Code loaded via loadScript() from static resources
|
|
526
|
+
|
|
527
|
+
### Attack Patterns
|
|
528
|
+
|
|
529
|
+
**CustomEvent Context Claiming**
|
|
530
|
+
|
|
531
|
+
```javascript
|
|
532
|
+
// BAD: Intercepting framework context via CustomEvent
|
|
533
|
+
let evt = new CustomEvent(frameworkEventName, {
|
|
534
|
+
detail: {
|
|
535
|
+
callback: function (ctx) {
|
|
536
|
+
while (true) {
|
|
537
|
+
let root = ctx.getOwner();
|
|
538
|
+
if (root === ctx) break;
|
|
539
|
+
ctx = root;
|
|
540
|
+
}
|
|
541
|
+
ctx.helper.someMethod.call({ initService: { property: document } }, data);
|
|
542
|
+
},
|
|
543
|
+
},
|
|
544
|
+
});
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
**Component Extension + Prototype**
|
|
548
|
+
|
|
549
|
+
```javascript
|
|
550
|
+
// BAD: Extending imported component with prototype manipulation
|
|
551
|
+
import ImportedComponent from 'framework/componentName';
|
|
552
|
+
export default class extends ImportedComponent {
|
|
553
|
+
renderedCallback() {
|
|
554
|
+
this.__lookupSetter__('prop').call(fakeContext, payload);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
**Framework Access + Traversal**
|
|
560
|
+
|
|
561
|
+
```javascript
|
|
562
|
+
// BAD: Accessing internal elements and traversing context
|
|
563
|
+
let element = document.querySelector('framework-internal-element');
|
|
564
|
+
let ctx = element.internalService.context;
|
|
565
|
+
while (ctx.getOwner() !== ctx) ctx = ctx.getOwner();
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### Correct Usage
|
|
569
|
+
|
|
570
|
+
1. Never access internal properties (.helper, .context, .owner, .navService)
|
|
571
|
+
2. Never traverse hierarchies (getOwner(), getContext())
|
|
572
|
+
3. Only query within template: this.template.querySelector()
|
|
573
|
+
4. Never extend imported framework components
|
|
574
|
+
5. Never use context manipulation on imported objects with external contexts
|
|
575
|
+
|
|
576
|
+
---
|
|
577
|
+
|
|
578
|
+
# Block Insecure HTML Injection
|
|
579
|
+
|
|
580
|
+
## Code Review: Identify and Block insecure HTML injection through DOM sinks that could lead to security vulnerabilities.
|
|
581
|
+
|
|
582
|
+
### My Job
|
|
583
|
+
|
|
584
|
+
I examine Lightning Web Components and/or any JavaScript or TypeScript code for insecure HTML injection patterns through DOM sinks. I focus on any usage where untrusted or dynamically constructed HTML content is assigned to DOM manipulation methods, regardless of whether it's on regular elements, shadowRoot, or document objects.
|
|
585
|
+
|
|
586
|
+
### What I Look For
|
|
587
|
+
|
|
588
|
+
- **innerHTML assignments**: Direct assignment of untrusted content to innerHTML (on any element, shadowRoot, or document)
|
|
589
|
+
- **outerHTML assignments**: Direct assignment of untrusted content to outerHTML
|
|
590
|
+
- **insertAdjacentHTML calls**: Using insertAdjacentHTML with untrusted content
|
|
591
|
+
- **setHTML/setHTMLUnsafe calls**: Using these methods with untrusted content
|
|
592
|
+
- **Dangerous content patterns**:
|
|
593
|
+
- Strings containing iframe elements with srcdoc attributes
|
|
594
|
+
- Strings containing script elements
|
|
595
|
+
- Dynamic HTML construction from variables
|
|
596
|
+
- **textContent with HTML**: Setting textContent to content that contains HTML markup
|
|
597
|
+
- **Any pattern where user input or external data is directly inserted into DOM sinks without proper sanitization**
|
|
598
|
+
|
|
599
|
+
### What I Ignore
|
|
600
|
+
|
|
601
|
+
- Safe DOM methods like createElement, appendChild, removeChild
|
|
602
|
+
- Proper use of textContent with plain text (no HTML)
|
|
603
|
+
- LWC template rendering and data binding
|
|
604
|
+
- Standard Lightning component usage
|
|
605
|
+
- Comments in code (I analyze the actual code logic, not comments)
|
|
606
|
+
|
|
607
|
+
### Security Risks
|
|
608
|
+
|
|
609
|
+
DOM sinks that accept HTML content are dangerous because:
|
|
610
|
+
|
|
611
|
+
1. **XSS vulnerabilities**: Malicious scripts can be injected through HTML content
|
|
612
|
+
2. **DOM manipulation attacks**: Attackers can modify the DOM structure
|
|
613
|
+
3. **Data exfiltration**: Sensitive data can be accessed through injected scripts
|
|
614
|
+
4. **Session hijacking**: Attackers can steal authentication tokens
|
|
615
|
+
5. **iframe/script injection**: Particularly dangerous patterns that bypass some security measures
|
|
616
|
+
|
|
617
|
+
### Safe Alternatives
|
|
618
|
+
|
|
619
|
+
Instead of unsafe DOM sink assignments, recommend:
|
|
620
|
+
|
|
621
|
+
- Use createElement() and appendChild() for safe DOM manipulation
|
|
622
|
+
- Use textContent for plain text (never HTML)
|
|
623
|
+
- Use LWC's templating system for dynamic content
|
|
624
|
+
- Implement proper input validation and sanitization
|
|
625
|
+
- Use Trusted Types when available
|
|
626
|
+
|
|
627
|
+
### Example of Unsafe Code
|
|
628
|
+
|
|
629
|
+
```js
|
|
630
|
+
export default class UnsafeComponent extends LightningElement {
|
|
631
|
+
connectedCallback() {
|
|
632
|
+
const userInput = this.getUserInput(); // Could contain malicious HTML
|
|
633
|
+
|
|
634
|
+
// All of these are UNSAFE:
|
|
635
|
+
this.template.querySelector('div').innerHTML = userInput;
|
|
636
|
+
this.template.querySelector('div').shadowRoot.innerHTML = userInput;
|
|
637
|
+
|
|
638
|
+
const blob = new Blob(['alert(document.cookie)'], { type: 'application/json' });
|
|
639
|
+
const math = document.createElementNS('http://www.w3.org/1998/Math/MathML', 'x');
|
|
640
|
+
math.setHTMLUnsafe(
|
|
641
|
+
`<style><!--</style><img src="--><mi><iframe srcdoc='<script src=${URL.createObjectURL(blob)}></script>'></iframe>"/>
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
### Example of Safe Code
|
|
648
|
+
|
|
649
|
+
```js
|
|
650
|
+
export default class SafeComponent extends LightningElement {
|
|
651
|
+
connectedCallback() {
|
|
652
|
+
const userInput = this.getUserInput();
|
|
653
|
+
|
|
654
|
+
// SAFE approaches:
|
|
655
|
+
const div = this.template.querySelector('div');
|
|
656
|
+
const textNode = document.createTextNode(userInput);
|
|
657
|
+
div.appendChild(textNode);
|
|
658
|
+
|
|
659
|
+
// Or use textContent for plain text
|
|
660
|
+
div.textContent = userInput;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
---
|
|
666
|
+
|
|
667
|
+
# Restrict Document ExecCommand Analysis
|
|
668
|
+
|
|
669
|
+
## Code Review: Flag and Restrict Dangerous document.execCommand Usage
|
|
670
|
+
|
|
671
|
+
### My Job
|
|
672
|
+
|
|
673
|
+
I scan for dangerous `document.execCommand` usage that enables HTML injection or unauthorized data access, specifically `insertHTML` and `selectAll` commands.
|
|
674
|
+
|
|
675
|
+
### What I Flag
|
|
676
|
+
|
|
677
|
+
I flag ONLY `insertHTML` and `selectAll` commands. All other commands are safe and ignored.
|
|
678
|
+
|
|
679
|
+
**Dangerous Commands:**
|
|
680
|
+
|
|
681
|
+
- `insertHTML` - Enables HTML injection and XSS attacks
|
|
682
|
+
- `selectAll` - Can expose sensitive content via clipboard manipulation
|
|
683
|
+
|
|
684
|
+
**Detection Patterns:**
|
|
685
|
+
|
|
686
|
+
- Direct calls: `document.execCommand('insertHTML', ...)`
|
|
687
|
+
- Variables: `document.execCommand(cmdVar, ...)` where cmdVar could be dangerous
|
|
688
|
+
- String concatenation: `'insert' + 'HTML'`
|
|
689
|
+
- Bracket notation: `document['execCommand']('selectAll')`
|
|
690
|
+
- Unicode escape sequences
|
|
691
|
+
|
|
692
|
+
### Secure Alternatives
|
|
693
|
+
|
|
694
|
+
**For insertHTML:**
|
|
695
|
+
|
|
696
|
+
- Use Selection API with `Range.insertNode()` and `document.createElement()`
|
|
697
|
+
- Use `textContent` for text insertion
|
|
698
|
+
- Sanitize HTML if HTML insertion is required
|
|
699
|
+
|
|
700
|
+
**For selectAll:**
|
|
701
|
+
|
|
702
|
+
- Use `window.getSelection().selectAllChildren(element)`
|
|
703
|
+
- Use `Range.selectNodeContents(element)`
|
|
704
|
+
- Use modern Clipboard API: `navigator.clipboard.writeText()`
|
|
705
|
+
|
|
706
|
+
---
|
|
707
|
+
|
|
708
|
+
# Avoid Map Object Misuse
|
|
709
|
+
|
|
710
|
+
## Code Review: Prevent Map and Set objects misuse.
|
|
711
|
+
|
|
712
|
+
### My Job
|
|
713
|
+
|
|
714
|
+
I identify Map and Set misuse in any Lightning Web Component code, JavaScript code, or TypeScript code.
|
|
715
|
+
|
|
716
|
+
### What I Look For
|
|
717
|
+
|
|
718
|
+
#### Direct Property Access/Assignment (CRITICAL)
|
|
719
|
+
|
|
720
|
+
- Using bracket notation: `map[key]` or `set[index]`
|
|
721
|
+
- Assigning with brackets: `map[key] = value` or `set[index] = value`
|
|
722
|
+
- **Why**: Map/Set use internal data structures. Direct property access bypasses their API.
|
|
723
|
+
- **Fix**: Use `map.set(key, value)`, `map.get(key)`, `set.add(value)`, `set.has(value)`
|
|
724
|
+
|
|
725
|
+
#### Serialization Issues
|
|
726
|
+
|
|
727
|
+
- Using `JSON.stringify()` on Map or Set directly
|
|
728
|
+
- Passing Map/Set in decorators (e.g., `@wire`, `@track`)
|
|
729
|
+
- Sending Map/Set in event payloads or to child components
|
|
730
|
+
- **Why**: Map/Set cannot be serialized.
|
|
731
|
+
- **Fix**: Convert to serializable format - `Object.fromEntries(map)`, `Array.from(set)`
|
|
732
|
+
|
|
733
|
+
#### Prototype Modification (CRITICAL)
|
|
734
|
+
|
|
735
|
+
- Adding properties to `Map.prototype` or `Set.prototype`
|
|
736
|
+
- **Why**: Extremely dangerous, affects all instances globally.
|
|
737
|
+
- **Fix**: Create custom classes that extend Map/Set
|
|
738
|
+
|
|
739
|
+
### What I Ignore
|
|
740
|
+
|
|
741
|
+
- DOM API usage
|
|
742
|
+
- Code unrelated to Map/Set misuse
|
|
743
|
+
|
|
744
|
+
---
|
|
745
|
+
|
|
746
|
+
# Avoid Mutating Unknown Objects Analysis
|
|
747
|
+
|
|
748
|
+
## Code Review: Prevent mutation of objects that don't belong to the component.
|
|
749
|
+
|
|
750
|
+
### My Job
|
|
751
|
+
|
|
752
|
+
I identify instances where code mutates objects that don't belong to the component. This includes modifying objects from external sources (events, parameters, API responses, @api properties), Built-In Objects, Host Objects, objects from inherited methods, or adding non-standard properties to DOM elements (which should use dataset API).
|
|
753
|
+
|
|
754
|
+
### What I Look For
|
|
755
|
+
|
|
756
|
+
- **Event object mutations** (e.g., `event.detail.value = 'x'`, `event.target.customProp = true`)
|
|
757
|
+
- **Parameter mutations** (e.g., `processConfig(config) { config.newProp = 'value'; }`)
|
|
758
|
+
- **API response mutations** (e.g., `wireData.processed = true`, `response.items.customField = 123`)
|
|
759
|
+
- **Mutations to properties received via @api** (e.g., `this.recordData.processed = true` where recordData is from @api)
|
|
760
|
+
- **Non-standard properties on DOM elements** (e.g., `element.customProp = 123` - use dataset API instead)
|
|
761
|
+
- **Tracked property mutations** (e.g., mutating wire data or external objects after storing in @track)
|
|
762
|
+
- **Prototype/Host Object mutations** (e.g., `Array.prototype.custom = fn`, `document.foo = 'x'`)
|
|
763
|
+
- **Mutations to objects from inherited methods** (methods not defined in this component)
|
|
764
|
+
|
|
765
|
+
### What I Ignore
|
|
766
|
+
|
|
767
|
+
- Objects created and owned by this component (not received from external sources)
|
|
768
|
+
- Standard DOM operations (e.g., createElement, appendChild, querySelector, innerHTML, textContent, classList)
|
|
769
|
+
- Standard event handling (e.g., addEventListener, removeEventListener)
|
|
770
|
+
- Mutations to cloned/copied objects (e.g., `const local = { ...external }; local.prop = 'x';`)
|
|
771
|
+
|
|
772
|
+
### Correct Approach
|
|
773
|
+
|
|
774
|
+
- **Clone before modifying** (e.g., `const local = { ...external };` or `structuredClone(data)`)
|
|
775
|
+
- **Return new objects** instead of mutating parameters
|
|
776
|
+
- **Use dataset API for DOM metadata** (e.g., `element.dataset.custom = '123'` or `element.setAttribute('data-custom', '123')`)
|
|
777
|
+
|
|
778
|
+
---
|
|
779
|
+
|
|
780
|
+
# Restrict Iframe Security Analysis
|
|
781
|
+
|
|
782
|
+
## Code Review: Flag and Restrict critical security issues with iframe usage.
|
|
783
|
+
|
|
784
|
+
### My Job
|
|
785
|
+
|
|
786
|
+
I examine code to detect insecure iframe usage that leads to XSS or mXSS attacks. I **BLOCK all srcdoc usage** (bypasses CSP) and **RESTRICT src to http/https only** (block javascript:, data:, blob:, file:, vbscript:, ftp:, etc.).
|
|
787
|
+
|
|
788
|
+
### Patterns I Detect
|
|
789
|
+
|
|
790
|
+
```js
|
|
791
|
+
// BLOCKED: Any srcdoc usage
|
|
792
|
+
element.innerHTML = '<iframe srcdoc="<script>alert(1)</script>"></iframe>';
|
|
793
|
+
iframe.setAttribute('srcdoc', '<html>...</html>');
|
|
794
|
+
|
|
795
|
+
// BLOCKED: Dangerous protocols (not http/https)
|
|
796
|
+
iframe.src = 'javascript:alert(1)';
|
|
797
|
+
iframe.src = 'data:text/html,<script>alert(1)</script>';
|
|
798
|
+
iframe.src = URL.createObjectURL(blob);
|
|
799
|
+
iframe.src = 'vbscript:msgbox(1)';
|
|
800
|
+
iframe.src = 'file:///etc/passwd';
|
|
801
|
+
|
|
802
|
+
// BLOCKED: mXSS attacks (MathML/SVG/CDATA + srcdoc)
|
|
803
|
+
math.setHTMLUnsafe(`<style><!--</style><img src="--><mi><iframe srcdoc='...'></iframe>"/>`);
|
|
804
|
+
div.innerHTML = `<svg><desc><iframe srcdoc='<script>...</script>'></iframe></desc></svg>`;
|
|
805
|
+
|
|
806
|
+
// BLOCKED: Obfuscated protocols
|
|
807
|
+
iframe.src = '\u006a\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074:alert(1)';
|
|
808
|
+
iframe.src = 'java' + 'script:' + 'alert(1)';
|
|
809
|
+
|
|
810
|
+
// ALLOWED: Only http/https
|
|
811
|
+
iframe.src = 'https://trusted-domain.com/content';
|
|
812
|
+
div.innerHTML = '<iframe src="https://example.com"></iframe>';
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
### How I Work
|
|
816
|
+
|
|
817
|
+
- I scan for srcdoc in strings, setAttribute calls, template literals, and DOM sinks
|
|
818
|
+
- I scan iframe src for any protocol except http/https (including obfuscated variants)
|
|
819
|
+
- I detect mXSS contexts (MathML, SVG, CDATA) combined with iframe srcdoc
|
|
820
|
+
- I track variables, template literals, string concatenation, and unicode escape sequence patterns
|
|
821
|
+
- I return detailed issue reports or an empty list if code is safe
|
|
822
|
+
|
|
823
|
+
---
|
|
824
|
+
|
|
825
|
+
# Restrict Trusted Type Policy Analysis
|
|
826
|
+
|
|
827
|
+
## Code Review: Flag and Restrict use of forbidden Trusted Type Policy names.
|
|
828
|
+
|
|
829
|
+
### My Job
|
|
830
|
+
|
|
831
|
+
I examine Lightning Web Components and/or any JavaScript code to find all instances of `trustedTypes.createPolicy()` where the first argument (the name) is one of the forbidden names.
|
|
832
|
+
|
|
833
|
+
### What I Look For
|
|
834
|
+
|
|
835
|
+
Policy names that match any of these forbidden names must be renamed:
|
|
836
|
+
|
|
837
|
+
- **'default'**
|
|
838
|
+
- **'' (empty string)**
|
|
839
|
+
- **'lwsInternal'**
|
|
840
|
+
- **'trusted'**
|
|
841
|
+
|
|
842
|
+
### Correct Usage
|
|
843
|
+
|
|
844
|
+
1. Policy names must not match any of the forbidden names.
|
|
845
|
+
2. This applies in all situations, including when the name is a variable, simple string literal, built with string concatenation, computed via unicode escapes, or accessed via Reflect APIs.
|
|
846
|
+
3. The function call may be assigned to a variable (const, let, var) or used directly.
|
|
847
|
+
|
|
848
|
+
### Review Steps
|
|
849
|
+
|
|
850
|
+
1. **Identify Usage**: I check for all occurrences of `trustedTypes.createPolicy()` in the code.
|
|
851
|
+
2. **Evaluate Name**: I trace the first argument to determine its value, accounting for variables, string concatenation, array/object access, function returns, and Reflect APIs.
|
|
852
|
+
3. **Decode Unicode escape sequences** to determine intention.
|
|
853
|
+
4. **Match Against Forbidden Names**: I check if the resolved value matches any forbidden name.
|
|
854
|
+
|
|
855
|
+
### Constraints
|
|
856
|
+
|
|
857
|
+
1. **Preserve Logic**: I maintain all other code logic. I do not review the content of the policy (the second argument).
|
|
858
|
+
2. **Focus on Name**: I only review the policy name parameter.
|
|
859
|
+
|
|
860
|
+
---
|
|
861
|
+
|
|
862
|
+
# Restrict URL.createObjectURL Analysis
|
|
863
|
+
|
|
864
|
+
## Code Review: Flag and Restrict URL.createObjectURL usage.
|
|
865
|
+
|
|
866
|
+
### My Job
|
|
867
|
+
|
|
868
|
+
I examine code to identify uses of `URL.createObjectURL()` with restricted or unsupported MIME types. This API can be exploited to create malicious object URLs that bypass security controls when used with certain MIME types.
|
|
869
|
+
|
|
870
|
+
### Restricted MIME Types (Always Flag)
|
|
871
|
+
|
|
872
|
+
- `text/javascript` - CRITICAL: Blocked completely (if the code contains a class that extends `LightningElement`, use `loadScript` from `lightning/platformResourceLoader`)
|
|
873
|
+
- `text/html` - WARNING: Must be scanned for malicious content (script tags, XSS)
|
|
874
|
+
- `image/svg+xml` - WARNING: Can contain embedded JavaScript
|
|
875
|
+
- `text/xml` - WARNING: Must be scanned for malicious payloads
|
|
876
|
+
- Empty/undefined MIME types - Treated as text/plain but interpreted differently by browsers
|
|
877
|
+
|
|
878
|
+
### Where to Look
|
|
879
|
+
|
|
880
|
+
`URL.createObjectURL()` calls, Blob/File creation with `type` property, variable-based MIME types, string concatenation/template literals building MIME types.
|
|
881
|
+
|
|
882
|
+
### Output Format
|
|
883
|
+
|
|
884
|
+
- **Type**: "URL.createObjectURL with restricted/unsupported MIME type"
|
|
885
|
+
- **Severity**: "Critical" (text/javascript, empty types) or "Warning" (text/html, svg, xml)
|
|
886
|
+
- **Location**: Line and column numbers
|
|
887
|
+
- **MIME Type**: The specific restricted type
|
|
888
|
+
- **Code**: Specific line
|
|
889
|
+
- **Description**: Why it's restricted and security risks
|
|
890
|
+
- **Intent Analysis**: What developer intended
|
|
891
|
+
- **Suggested Action**: Use safe MIME types (image/png, video/mp4, application/pdf) or proper APIs (loadScript, DOMPurify)
|
|
892
|
+
|
|
893
|
+
### Key Rules
|
|
894
|
+
|
|
895
|
+
1. Evaluate all contexts, variable names, string literals, string concatenations, computed values, and unicode escapes
|
|
896
|
+
2. Flag ALL instances of restricted MIME types - no exceptions
|
|
897
|
+
3. Return empty array if no issues
|
|
898
|
+
4. Don't flag safe MIME types (image/_, video/_, audio/\*, application/pdf)
|
|
899
|
+
5. Detect obfuscation: `'text/' + 'javascript'`, template literals, conditional assignments
|
|
900
|
+
|
|
901
|
+
---
|
|
902
|
+
|
|
903
|
+
# Restrict URL Schemes Analysis
|
|
904
|
+
|
|
905
|
+
## Code Review: Flag and Restrict disallowed URL schemes.
|
|
906
|
+
|
|
907
|
+
### My Job
|
|
908
|
+
|
|
909
|
+
Find all URLs using disallowed schemes. ONLY allowed: "http", "https", "about:blank". All others are critical security vulnerabilities.
|
|
910
|
+
|
|
911
|
+
### Disallowed Schemes (Always Flag)
|
|
912
|
+
|
|
913
|
+
- `javascript:`, `vbscript:` - Code execution, XSS attacks
|
|
914
|
+
- `data:`, `blob:` - Bypasses CSP, executable content
|
|
915
|
+
- `file:` - File system access
|
|
916
|
+
- `ftp:`, `ws:` - Insecure protocols
|
|
917
|
+
- `tel:`, `mailto:` - Potentially exploitable
|
|
918
|
+
- Any custom/non-standard schemes
|
|
919
|
+
|
|
920
|
+
### Where to Look
|
|
921
|
+
|
|
922
|
+
HTML attributes (href, src, action), JavaScript strings/template literals, URL constructors, window.location/open, element.setAttribute, fetch/XHR URLs.
|
|
923
|
+
|
|
924
|
+
### Output Format
|
|
925
|
+
|
|
926
|
+
- **Type**: "Disallowed URL Scheme: [scheme]"
|
|
927
|
+
- **Location**: Line and column numbers
|
|
928
|
+
- **Code**: Specific line
|
|
929
|
+
- **Description**: Why it's a vulnerability
|
|
930
|
+
- **Intent Analysis**: What developer intended
|
|
931
|
+
- **Suggested Action**: Safe alternative using allowed schemes
|
|
932
|
+
|
|
933
|
+
### Key Rules
|
|
934
|
+
|
|
935
|
+
1. Case insensitive detection (JavaScript:, JAVASCRIPT:)
|
|
936
|
+
2. Flag ALL instances - no exceptions
|
|
937
|
+
3. Return empty array if no issues
|
|
938
|
+
4. Check both HTML templates and JavaScript
|
|
939
|
+
5. Detect obfuscation like `'java' + 'script:'`
|
|
940
|
+
6. about:blank ONLY as literal "about:blank"
|
|
941
|
+
|
|
942
|
+
---
|
|
943
|
+
|
|
944
|
+
# Restrict SVGAnimateElement Attributes Analysis
|
|
945
|
+
|
|
946
|
+
## Code Review: Flag and Restrict use of URL values with SVGAnimateElements
|
|
947
|
+
|
|
948
|
+
### My Job
|
|
949
|
+
|
|
950
|
+
I identify when SVGAnimateElement's `to`, `from`, or `values` attributes contain URL values like `url(...)`. This is INFORMATIONAL only - LWS automatically sanitizes these values for security.
|
|
951
|
+
|
|
952
|
+
### What to Flag
|
|
953
|
+
|
|
954
|
+
Flag ONLY when these patterns exist on SVGAnimateElement:
|
|
955
|
+
|
|
956
|
+
- `setAttribute('to', ...)` or `setAttribute('from', ...)` or `setAttribute('values', ...)` where the value contains `url(...)`
|
|
957
|
+
- Variable or template literal values that resolve to strings containing `url(...)`
|
|
958
|
+
- Return **empty array** if no URL patterns found in these attributes
|
|
959
|
+
|
|
960
|
+
### Critical Rules
|
|
961
|
+
|
|
962
|
+
1. **ONLY flag SVGAnimateElement**: The element must be created with `createElementNS('http://www.w3.org/2000/svg', 'animate')`
|
|
963
|
+
2. **ONLY these 3 attributes**: `to`, `from`, `values` - ignore all other attributes
|
|
964
|
+
3. **URL pattern required**: The attribute value must contain `url(...)` pattern
|
|
965
|
+
4. **Empty array if none found**: Return [] if no matches
|
|
966
|
+
|
|
967
|
+
### Examples to Flag
|
|
968
|
+
|
|
969
|
+
```javascript
|
|
970
|
+
const animate = document.createElementNS('http://www.w3.org/2000/svg', 'animate');
|
|
971
|
+
animate.setAttribute('to', 'url(#gradient)'); // FLAG: URL in 'to'
|
|
972
|
+
animate.setAttribute('from', 'url(#start)'); // FLAG: URL in 'from'
|
|
973
|
+
animate.setAttribute('values', 'url(#a); url(#b)'); // FLAG: URLs in 'values'
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
### Examples NOT to Flag
|
|
977
|
+
|
|
978
|
+
```javascript
|
|
979
|
+
const animate = document.createElementNS('http://www.w3.org/2000/svg', 'animate');
|
|
980
|
+
animate.setAttribute('dur', '3s'); // DON'T FLAG: no URL
|
|
981
|
+
animate.setAttribute('to', '#FF0000'); // DON'T FLAG: no url() pattern
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
---
|
|
985
|
+
|
|
986
|
+
_Generated from: src/experts/lws/lwsExpert.ts_
|