Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
**Vulnerability:** Use of `innerHTML` for dynamic content and missing Content Security Policy (CSP).
**Learning:** Even if the content is currently static, using `innerHTML` is a dangerous pattern that can lead to XSS if the application grows. Prefer `textContent` and explicit DOM node creation.
**Prevention:** Establish a strong CSP and enforce secure DOM manipulation practices through documentation and code reviews.

## 2025-02-12 - Defensive Component Creation & CSP Hardening
**Vulnerability:** Default button behavior and missing form-action restrictions.
**Learning:** Dynamically created buttons in JavaScript defaults to 'submit' in some contexts, which can lead to unexpected form submissions if wrapped in a form later. Additionally, a missing `form-action` directive in CSP leaves a gap for data exfiltration via form injection.
**Prevention:** Always explicitly set `button.type = 'button'` for non-submitting buttons. Harden CSP with `form-action 'none'` if the application does not use forms.
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'sha256-fgxmLOznNmVf4GAd24jy5Eiv/Rer+7sVLOBqnsVx0nY='; script-src 'self' 'sha256-cPRnZP+O4z5KsN+vdFstQwgKExGtoN98I3Gq+Tm1aSA='; object-src 'none'; base-uri 'self'; upgrade-insecure-requests;">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'sha256-fgxmLOznNmVf4GAd24jy5Eiv/Rer+7sVLOBqnsVx0nY='; script-src 'self' 'sha256-hvwTAsl77xNtXkz49ZgA5OjaXlOZ0QtLjxGpvlAsfe8='; object-src 'none'; base-uri 'self'; form-action 'none'; upgrade-insecure-requests;">
<meta name="referrer" content="no-referrer">
<title>5ive - UX Sample</title>
<style>
Expand Down Expand Up @@ -167,18 +167,21 @@ <h1>Welcome to 5ive</h1>
feedback.appendChild(content);

const closeBtn = document.createElement('button');
// ✅ Sentinel: Explicitly set type to prevent accidental form submission
closeBtn.type = 'button';
closeBtn.className = 'close-btn';
closeBtn.setAttribute('aria-label', 'Close notification');
closeBtn.textContent = '×';
closeBtn.onclick = () => {
// ✅ Sentinel: Use addEventListener for better security and maintainability
closeBtn.addEventListener('click', () => {
if (feedbackTimeout) clearTimeout(feedbackTimeout);
feedback.classList.remove('visible');
setTimeout(() => {
if (!feedback.classList.contains('visible')) {
feedback.textContent = '';
}
}, 300);
};
});
feedback.appendChild(closeBtn);

// Trigger reflow/transition
Expand Down