Automated summary
This skill performs a comprehensive security audit of dynamically loaded JavaScript dependencies, identifying risks and proposing fixes.
Strengths
- Covers discovery of all dynamic loading patterns (script tags, dynamic imports, iframes, web workers).
- Evaluates supply chain, XSS, iframe, and transport security risks.
- Includes a best practices checklist for CSP, SRI, and sandboxing.
Limitations
- Does not execute dynamic code, so may miss runtime-generated scripts.
- Requires access to full codebase; limited if only partial code is available.
- May not catch all advanced obfuscated loading techniques.
Use when auditing a web application's security posture regarding third-party and dynamic scripts, especially before deployment.
Not for real-time monitoring or runtime security testing; complementary to dynamic analysis.
Security analysis
SafeThe skill is a guide for auditing JavaScript dependency loading and does not contain any instructions that would cause harmful actions, data exfiltration, or execution of destructive commands. It is purely analytical.
No concerns found
How this analysis is madeExamples
Run a comprehensive security audit of all dynamically loaded JavaScript in this web application. Identify risks and propose fixes.Audit all third-party JavaScript dependencies loaded dynamically. Check for SRI, CSP, and supply chain risks.name: dynamic-js-audit description: Auditing dynamically loaded JavaScript
Claude Code Prompt: JavaScript Dependency & Dynamic Loading Security Audit
Purpose
Perform a comprehensive security audit of dynamically loaded JavaScript dependencies in this web application. Identify security risks, check adherence to best practices, and propose non-breaking patches or alternatives.
Instructions
Phase 1: Discovery - Find All Dynamic JavaScript Loading
Scan the entire codebase for dynamically loaded JavaScript. Look for:
1. Script Tag Injection Patterns:
- <script src="..."> tags in HTML files
- document.createElement('script')
- element.innerHTML containing <script>
- document.write() with script content
- insertAdjacentHTML() with scripts
2. Dynamic Import Mechanisms:
- import() dynamic imports
- require() with variable paths
- System.import()
- AMD define() and require()
- Webpack's require.ensure()
- Code splitting chunks
3. External Resource Loading:
- CDN-hosted libraries (cdnjs, jsdelivr, unpkg, etc.)
- Third-party analytics scripts (Google Analytics, Mixpanel, etc.)
- Advertising scripts
- Social media widgets
- Payment processors (Stripe, PayPal SDKs)
- Chat widgets (Intercom, Drift, etc.)
- A/B testing tools
4. Iframe Sources:
- <iframe src="..."> tags
- Dynamically created iframes
- postMessage() communication patterns
5. Web Workers & Service Workers:
- new Worker() instantiations
- Service worker registrations
- Shared workers
For each discovered instance, record:
- File path and line number
- The URL/source being loaded
- Whether it's first-party or third-party
- Loading context (inline, deferred, async, module)
- Any existing security measures in place
Phase 2: Security Risk Assessment
Evaluate each dynamically loaded resource against these risk categories:
A. Supply Chain Risks:
- [ ] Is Subresource Integrity (SRI) used for external scripts?
- [ ] Are specific versions pinned or using
latest/unpinned versions? - [ ] Is the CDN/source reputable and unlikely to be compromised?
- [ ] Could the external resource be self-hosted instead?
B. Cross-Site Scripting (XSS) Vectors:
- [ ] Is user input ever used in script URLs or content?
- [ ] Are there proper Content Security Policy (CSP) headers?
- [ ] Is innerHTML/outerHTML used with untrusted content?
- [ ] Are template literals interpolating external data into scripts?
C. Iframe Security:
- [ ] Do iframes use the
sandboxattribute? - [ ] Is
allow-scriptsgranted only when necessary? - [ ] Is
allow-same-origincombined dangerously withallow-scripts? - [ ] Are proper
allowfeature policies set? - [ ] Is the
referrerpolicyattribute set appropriately?
D. Protocol & Transport Security:
- [ ] Are all external resources loaded over HTTPS?
- [ ] Are there any protocol-relative URLs (
//example.com)? - [ ] Is mixed content possible?
E. Data Exposure Risks:
- [ ] Do third-party scripts have access to sensitive DOM content?
- [ ] Are cookies properly scoped (HttpOnly, Secure, SameSite)?
- [ ] Is localStorage/sessionStorage accessible to third-party scripts?
- [ ] Are postMessage handlers validating origin?
Phase 3: Best Practices Checklist
For each category, check implementation status:
Content Security Policy (CSP):
- script-src directive configured
- No 'unsafe-inline' without nonces/hashes
- No 'unsafe-eval' unless absolutely required
- Specific domains whitelisted (no wildcards)
- report-uri configured for monitoring
Subresource Integrity (SRI):
- integrity attribute on all external scripts
- crossorigin="anonymous" set when using SRI
- SRI hashes match current library versions
Iframe Sandboxing:
- sandbox attribute present on all third-party iframes
- Minimal permissions granted (principle of least privilege)
- Feature policy/Permissions-Policy configured
Script Loading Security:
- async/defer used appropriately
- Scripts loaded from trusted origins only
- Fallback mechanisms for CDN failures
- Error handling for failed script loads
postMessage Security:
- Origin validation in all message handlers
- Structured data validation
- No eval() of received messages
Phase 4: Generate Report & Patches
For each identified issue, provide:
1. Issue Description:
- What the vulnerability/risk is
- Where it's located (file:line)
- Severity rating (Critical/High/Medium/Low/Info)
- Potential impact if exploited
2. Proposed Patch: Provide a code diff showing the fix. Consider:
- The application's architecture and patterns
- Existing build tools and workflows
- Browser compatibility requirements
- Performance implications
- Whether the fix might break existing functionality
Format patches as:
// File: path/to/file.js
// Line: XX-YY
// Risk: [severity]
- <original code>
+ <patched code>
3. Explanation:
- Why the patch works
- Any trade-offs or considerations
- Testing recommendations
4. Alternatives (when direct fix isn't possible): If a best practice cannot be directly implemented, suggest:
- Compensating controls
- Alternative libraries or approaches
- Configuration changes
- Architecture modifications
- Monitoring/detection strategies as interim measures
Phase 5: Prioritized Remediation Plan
Organize findings into an actionable remediation plan:
-
Immediate Actions (Critical/High):
- Issues that could lead to RCE or data exfiltration
- Missing SRI on widely-used external scripts
- XSS vectors in script loading
-
Short-term Improvements (Medium):
- CSP implementation or hardening
- Iframe sandboxing gaps
- Protocol upgrades
-
Long-term Enhancements (Low/Info):
- Self-hosting external dependencies
- Build process improvements
- Monitoring and alerting setup
Output Format
Structure your response as:
# JavaScript Dependency Security Audit Report
## Executive Summary
[Brief overview of findings and risk posture]
## Discovery Results
[Table of all dynamically loaded scripts/resources found]
## Findings
### [SEVERITY] Finding #1: [Title]
**Location:** `path/to/file.js:XX`
**Description:** [What's wrong]
**Risk:** [Potential impact]
#### Current Code:
\`\`\`javascript
// problematic code
\`\`\`
#### Proposed Patch:
\`\`\`diff
- problematic code
+ fixed code
\`\`\`
#### Explanation:
[Why this fix works and considerations]
#### Alternatives (if applicable):
[Other approaches if the primary fix isn't viable]
---
[Repeat for each finding]
## Remediation Roadmap
[Prioritized list of actions]
## Additional Recommendations
[General hardening suggestions]
Special Considerations
Do NOT:
- Modify any files directly
- Propose changes that would break core functionality
- Suggest removing necessary third-party integrations without alternatives
- Recommend security measures incompatible with the app's tech stack
DO:
- Consider the full context of how each script is used
- Check for existing security measures before flagging issues
- Provide fallback options for essential functionality
- Note when manual review is needed for complex cases
- Consider framework-specific solutions (React, Vue, Angular, etc.)
Begin Audit
Start by exploring the project structure to understand the application architecture, then systematically scan for dynamically loaded JavaScript following the phases above.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/dynamic-javascript-security-audit-mma3js43/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/dynamic-javascript-security-audit-mma3js43' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/dynamic-javascript-security-audit-mma3js43/download' --output '.skill-downloads/dynamic-javascript-security-audit-mma3js43/SKILL.md.part' && mv '.skill-downloads/dynamic-javascript-security-audit-mma3js43/SKILL.md.part' '.skill-downloads/dynamic-javascript-security-audit-mma3js43/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/dynamic-javascript-security-audit-mma3js43/SKILL.md' && test -s '.skill-downloads/dynamic-javascript-security-audit-mma3js43/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/dynamic-js-audit' && cp -R '.skill-downloads/dynamic-javascript-security-audit-mma3js43' '.claude/skills/dynamic-js-audit'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/dynamic-javascript-security-audit-mma3js43'openskills read 'dynamic-javascript-security-audit-mma3js43'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/dynamic-javascript-security-audit-mma3js43/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
DeFi AMM Security
Security
Security checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, donation attacks, oracle manipulation, slippage, and integer math.
Semgrep Rule Creator
Security
Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Includes test-first methodology, taint mode support, and validation steps. Helps when building targeted static analysis detections.
Dev Toolbar Review Guide
Security
Safety rules for the dev toolbar, PostHog client, and feature flags. Use when reviewing changes to dev-tools and related files, covering environment guards, override cookies, and SSE stream safety.