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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
**Vulnerability:** A `constant_time_eq` implementation iterated `max(a.len(), b.len())` times, exposing a DoS vector where a large input would cause excessive CPU usage.
**Learning:** Attempts to "avoid leaking length" by checking all bytes can inadvertently introduce algorithmic complexity vulnerabilities. Standard practice is to check length first (leaking length but preventing DoS) and then compare in constant time.
**Prevention:** Prefer `subtle` crate or idiomatic constant-time comparisons that explicitly handle length checks to bound execution time.
## 2024-06-27 - XSS in Content Security Policy
**Vulnerability:** The default production Content Security Policy (CSP) included 'unsafe-inline' and 'unsafe-eval' in script-src and style-src directives.
**Learning:** Development CSP configurations frequently bleed into production defaults if strictness is not explicitly enforced. Permitting 'unsafe-inline' and 'unsafe-eval' severely undermines CSP protections against Cross-Site Scripting (XSS).
**Prevention:** Ensure production CSP strictly defines directives without 'unsafe-*' keywords. Apply permissive CSP solely in explicitly configured development environments.
4 changes: 2 additions & 2 deletions crates/app-http/src/middleware/security_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ pub struct SecurityHeadersConfig {
impl Default for SecurityHeadersConfig {
fn default() -> Self {
Self {
// Strict CSP for production, more permissive for development
// Strict CSP for production by default
content_security_policy: Some(
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
"default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),
x_frame_options: "DENY".to_string(),
x_content_type_options: "nosniff".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions crates/http-middleware/src/security_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ pub struct SecurityHeadersConfig {
impl Default for SecurityHeadersConfig {
fn default() -> Self {
Self {
// Strict CSP for production, more permissive for development
// Strict CSP for production by default
content_security_policy: Some(
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
"default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),
x_frame_options: "DENY".to_string(),
x_content_type_options: "nosniff".to_string(),
Expand Down
Loading