Problems with Download Manager and CSP Policy

Viewing 2 posts - 1 through 2 (of 2 total)
#206754

Paul
Member

Hi there,
I’m trying to implement a secure CSP policy and i’ve gone ahead and implemented a Nonce for my my scripts but I can’t seem to get it to work with the style-src. In order for Download Manager to function it needs the ‘unsafe-inline’; parameter. Is there a way around this as this exposes my entire site to XSS hacks.

#206757

Nayeem Riddhi
Moderator

Hello Paul,

This is a common security challenge when balancing CSP strictness with plugin functionality. Here are several approaches to work around the Download Manager’s unsafe-inline requirement:

## Immediate Solutions

1. Use a Nonce for Inline Styles
Instead of unsafe-inline, try implementing nonces for the Download Manager’s inline styles:

Content-Security-Policy: style-src 'self' 'nonce-[your-random-nonce]'

You’ll need to add the nonce attribute to any inline <style> tags the plugin generates.

2. Hash-Based Approach
Calculate SHA256 hashes of the specific inline styles and whitelist them:


Content-Security-Policy: style-src 'self' 'sha256-[hash-of-inline-style]'

## Better Long-term Solutions

3. Extract Inline Styles
– Create a separate CSS file containing the Download Manager’s styles
– Remove the inline styles from the plugin
– Include the CSS file with style-src 'self'

## Testing Your Implementation

Use browser dev tools to identify exactly which inline styles are being blocked, then target those specific elements with nonces or hashes.

Please kindly check.

Thank you and regards

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.