|
| 1 | +# Security Policy |
| 2 | + |
| 3 | +## Supported Versions |
| 4 | + |
| 5 | +We actively support the following versions of the NHS FDP Design System with security updates: |
| 6 | + |
| 7 | +| Version | Supported | |
| 8 | +| ------- | ------------------ | |
| 9 | +| 0.0.x (alpha) | :white_check_mark: | |
| 10 | + |
| 11 | +**Note:** This project is currently in alpha. Once we reach v1.0.0, we will maintain the current major version and the previous major version with security updates. |
| 12 | + |
| 13 | +## Reporting a Vulnerability |
| 14 | + |
| 15 | +We take security vulnerabilities seriously. If you discover a security vulnerability in the NHS FDP Design System, please report it responsibly. |
| 16 | + |
| 17 | +### How to Report |
| 18 | + |
| 19 | +**Please DO NOT report security vulnerabilities through public GitHub issues.** |
| 20 | + |
| 21 | +Instead, please report vulnerabilities through one of the following methods: |
| 22 | + |
| 23 | +1. **GitHub Security Advisories** (Preferred): |
| 24 | + - Navigate to the [Security Advisories](https://github.com/fergusbisset/nhs-fdp-design-system/security/advisories) page |
| 25 | + - Click "Report a vulnerability" |
| 26 | + - Fill in the details of the vulnerability |
| 27 | + |
| 28 | +2. **Email**: |
| 29 | + - Send details to the repository maintainer |
| 30 | + - Include "SECURITY" in the subject line |
| 31 | + - Provide a detailed description of the vulnerability |
| 32 | + |
| 33 | +### What to Include |
| 34 | + |
| 35 | +When reporting a vulnerability, please include: |
| 36 | + |
| 37 | +- **Type of vulnerability** (e.g., XSS, CSRF, injection, etc.) |
| 38 | +- **Full paths of source file(s)** related to the vulnerability |
| 39 | +- **Location of the affected source code** (tag/branch/commit or direct URL) |
| 40 | +- **Step-by-step instructions** to reproduce the issue |
| 41 | +- **Proof-of-concept or exploit code** (if possible) |
| 42 | +- **Impact of the vulnerability** - what can an attacker accomplish? |
| 43 | +- **Your contact information** for follow-up questions |
| 44 | + |
| 45 | +### What to Expect |
| 46 | + |
| 47 | +After you submit a vulnerability report: |
| 48 | + |
| 49 | +- **Acknowledgment**: We will acknowledge receipt within **48 hours** |
| 50 | +- **Assessment**: We will assess the vulnerability and determine its severity within **5 business days** |
| 51 | +- **Updates**: We will keep you informed of our progress |
| 52 | +- **Resolution**: We will work to release a fix as quickly as possible: |
| 53 | + - **Critical vulnerabilities**: Patched within 7 days |
| 54 | + - **High severity**: Patched within 14 days |
| 55 | + - **Medium/Low severity**: Patched in next regular release |
| 56 | +- **Credit**: We will credit you in the security advisory (unless you prefer to remain anonymous) |
| 57 | + |
| 58 | +## Security Best Practices for Users |
| 59 | + |
| 60 | +When using the NHS FDP Design System in your applications: |
| 61 | + |
| 62 | +### 1. Keep Dependencies Updated |
| 63 | + |
| 64 | +```bash |
| 65 | +# Check for security vulnerabilities |
| 66 | +npm audit |
| 67 | + |
| 68 | +# Update to latest patch versions |
| 69 | +npm update |
| 70 | + |
| 71 | +# Update to latest version |
| 72 | +npm install @fergusbisset/nhs-fdp-design-system@latest |
| 73 | +``` |
| 74 | + |
| 75 | +### 2. Content Security Policy (CSP) |
| 76 | + |
| 77 | +If you're using components with inline styles or dynamic content, configure your CSP headers appropriately: |
| 78 | + |
| 79 | +``` |
| 80 | +Content-Security-Policy: |
| 81 | + default-src 'self'; |
| 82 | + style-src 'self' 'unsafe-inline'; |
| 83 | + script-src 'self'; |
| 84 | +``` |
| 85 | + |
| 86 | +**Note:** Some components may require `'unsafe-inline'` for styles. We're working to eliminate this requirement. |
| 87 | + |
| 88 | +### 3. Server-Side Rendering (SSR) Security |
| 89 | + |
| 90 | +When using SSR components: |
| 91 | + |
| 92 | +- Always sanitize user input before passing to components |
| 93 | +- Use the SSR-safe variants (`/ssr` exports) in server contexts |
| 94 | +- Validate all data before rendering |
| 95 | +- Never trust client-provided data in server components |
| 96 | + |
| 97 | +Example: |
| 98 | +```tsx |
| 99 | +// ❌ DON'T: Unsanitized user input |
| 100 | +<Header serviceName={userInput} /> |
| 101 | + |
| 102 | +// ✅ DO: Sanitize input |
| 103 | +import DOMPurify from 'isomorphic-dompurify'; |
| 104 | +<Header serviceName={DOMPurify.sanitize(userInput)} /> |
| 105 | +``` |
| 106 | + |
| 107 | +### 4. Accessibility & Security |
| 108 | + |
| 109 | +Many security vulnerabilities arise from accessibility issues: |
| 110 | + |
| 111 | +- Use semantic HTML (provided by our components) |
| 112 | +- Ensure proper ARIA labels |
| 113 | +- Validate form inputs |
| 114 | +- Use our form validation components |
| 115 | + |
| 116 | +### 5. XSS Prevention |
| 117 | + |
| 118 | +Our components escape user content by default, but: |
| 119 | + |
| 120 | +- Never use `dangerouslySetInnerHTML` with user content |
| 121 | +- Sanitize any HTML before rendering |
| 122 | +- Use our built-in input validation components |
| 123 | +- Be cautious with `href` attributes in links |
| 124 | + |
| 125 | +```tsx |
| 126 | +// ❌ DANGEROUS |
| 127 | +<Button href={userProvidedUrl}>Click me</Button> |
| 128 | + |
| 129 | +// ✅ SAFE |
| 130 | +import { isValidUrl } from './utils'; |
| 131 | +const safeUrl = isValidUrl(userProvidedUrl) ? userProvidedUrl : '#'; |
| 132 | +<Button href={safeUrl}>Click me</Button> |
| 133 | +``` |
| 134 | + |
| 135 | +## Known Security Considerations |
| 136 | + |
| 137 | +### Progressive Enhancement Behaviors |
| 138 | + |
| 139 | +Our behavior layer (client-side enhancement) uses `data-*` attributes: |
| 140 | + |
| 141 | +- Behaviors are opt-in and don't execute unless explicitly imported |
| 142 | +- No `eval()` or `Function()` constructors are used |
| 143 | +- All event handlers are properly scoped |
| 144 | +- Behaviors can be safely torn down with `teardownAll()` |
| 145 | + |
| 146 | +### Design Tokens |
| 147 | + |
| 148 | +Design tokens are generated at build time and injected as CSS variables: |
| 149 | + |
| 150 | +- No runtime token generation |
| 151 | +- No user-controllable token values |
| 152 | +- Tokens are static and type-safe |
| 153 | + |
| 154 | +### Data Visualization Components |
| 155 | + |
| 156 | +D3 and visualization components: |
| 157 | + |
| 158 | +- SVG elements are properly escaped |
| 159 | +- No user-controlled `<script>` injection |
| 160 | +- Data is validated before rendering |
| 161 | +- Use our provided data validation utilities |
| 162 | + |
| 163 | +## Security Tools in This Repository |
| 164 | + |
| 165 | +We use the following automated security tools: |
| 166 | + |
| 167 | +- **Dependabot**: Automated dependency updates and vulnerability alerts |
| 168 | +- **npm audit**: Checks for known vulnerabilities in dependencies |
| 169 | +- **CodeQL**: Static analysis for security vulnerabilities |
| 170 | +- **Dependency Review**: Automated review of dependency changes in PRs |
| 171 | + |
| 172 | +## Security Release Process |
| 173 | + |
| 174 | +When we release a security fix: |
| 175 | + |
| 176 | +1. **Private Fix**: We develop the fix in a private branch |
| 177 | +2. **Security Advisory**: We create a GitHub Security Advisory |
| 178 | +3. **Patch Release**: We release a patch version (e.g., 0.0.44 → 0.0.45) |
| 179 | +4. **Notification**: We notify users through: |
| 180 | + - GitHub Security Advisory |
| 181 | + - Release notes |
| 182 | + - npm security advisories (when published to npm) |
| 183 | +5. **Disclosure**: After users have had time to update (typically 30 days), we publish full details |
| 184 | + |
| 185 | +## Scope |
| 186 | + |
| 187 | +This security policy applies to: |
| 188 | + |
| 189 | +- ✅ The `@fergusbisset/nhs-fdp-design-system` package |
| 190 | +- ✅ All components in the design system |
| 191 | +- ✅ Build tools and scripts that ship with the package |
| 192 | +- ✅ Documentation and example code |
| 193 | +- ❌ Third-party dependencies (report to their respective maintainers) |
| 194 | +- ❌ Applications built using this design system (your responsibility) |
| 195 | + |
| 196 | +## Contact |
| 197 | + |
| 198 | +For security-related questions that are not vulnerability reports: |
| 199 | + |
| 200 | +- Open a [GitHub Discussion](https://github.com/fergusbisset/nhs-fdp-design-system/discussions) |
| 201 | +- Tag your discussion with "security" |
| 202 | + |
| 203 | +## Acknowledgments |
| 204 | + |
| 205 | +We appreciate the security research community and will acknowledge contributors who report valid security issues (with their permission). |
| 206 | + |
| 207 | +--- |
| 208 | + |
| 209 | +**Last Updated**: 2025-01-22 |
0 commit comments