miniBB ®miniBB®
Support Forums
  
 · Start · Sign in · Register · Search · Statistics · File Bank · Manual ·
The Other miniBB Support Forums / The Other /  
 

Primary miniBB scripts for CSP

 
 
Page  Page 1 of 2 :  1  2  Next »

Author Frédéric
Guest
#1 · Posted: 14 Oct 2026 19:57
Hello,

Could you tell me which scripts on your forum are primary scripts?

If I recall correctly, there are only two.

For 2 websites, I want to differentiate the CSP parameters for `script-src` and `style-src`:
on the main site: `self` with a nonce;
on the forum: `unsafe-inline`.

This requires me to declare a different header (Content-Security-Policy...) for the primary scripts.

I hope that makes sense.

Author Paul
Lead Lead Developer
#2 · Posted: 14 Oct 2026 20:12
Frédéric:
Could you tell me which scripts on your forum are primary scripts?
I suppose, you mean javascripts?

If so, they are all located under the /templates/ folder, and in default version they are form.js and common.js.

For the file-upload related add-ons, there is also addon_filecheck.js.

If by "CSP parameters" you mean Content Security Policy (Web Security), then I'd recommend to modify the web server's configuration (for example, .htaccess or httpd.conf for Apache or nginx.conf for Nginx), and not inject the directives directly into your HTML files inside the <head> section, adding HTML Meta Tag.

As far as I remember, miniBB javascript codes are strictly tied up with the default HTML layout, and it is unpredictable if they would work with such directives or not. I cannot guarantee it and provide any kind of support in this case.

Author Frédéric
Guest
#3 · Posted: 15 Oct 2026 12:43
Hello Paul,

Paul:
I suppose, you mean javascripts?
No, i mean primary PHP scripts.

Where to put header directives (for CSP).

Is it clear ?

Author Paul
Lead Lead Developer
#4 · Posted: 15 Oct 2026 16:31
Frédéric:
Is it clear ?
Then it's not clear.

The primary PHP scripts are just index.php and bb_admin.php (or whatever it could be named).

But why would you need CSP for them?

It's naturally not possible to execute these scripts other than from the original domain.

Author Frédéric
Guest
#5 · Posted: 15 Oct 2026 21:37
Hello Paul,

There's a main website, and the forum is in a folder called `bb`.

In the `.htaccess` file, there's a `Header always set Content-Security-Policy` directive: `"default-src 'none'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline', etc..."`.

On the main website, `script-src` and `style-src` will be secured with a nonce, so `unsafe-inline` won't be used.

On the forum, because there are small pieces of JavaScript scattered throughout and inline CSS within the HTML (this isn't a criticism), it's impossible to use a nonce, and we have to keep `unsafe-inline`.

This separation is impossible in the `.htaccess` file.

The solution suggested by the Gemini AI is to remove this directive from the .htaccess file and place it in the primary PHP scripts.

In index.php and bb_admin.php:
Header (Content-Security-Policy: "default-src 'none'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline', etc..."

In the primary scripts of the main site:
Header (Content-Security-Policy: "default-src 'none'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; script-src 'self' 'nonce ???'; style-src 'self' 'nonce: ????', etc...")

Do you agree?

Author tom322
Active Member
#6 · Posted: 16 Oct 2026 03:40
I think you can use a different .htaccess in your /bb/ folder and then put the header with 'unsafe-inline' only in that folder's .htaccess, without adding a header to index.php or bb_admin.php.

Author Paul
Lead Lead Developer
#7 · Posted: 16 Oct 2026 10:04
I don't understand what purpose this all is for, that's why I couldn't give any comment until it's clear.

On your side, you must just understand what this all is for exactly on your website.

CSP is not a replacement for secure coding, so if you feel there is some leak in miniBB code, then it's a must to fix it at first and not just to slap CSP header on it.

Alternatively, you can try to set CSP in report-only mode and log any possible violations to check if you really need this.

Without understanding what you're doing it's quite easy to block your website from generic access.

Also, for me this all seems like a kids alarm preventing only obviously straight insecure cases. Professional hackers do not use regular browsers. The tools they use could bypass any headers.

Author Frédéric
Guest
#8 · Posted: 16 Oct 2026 12:40
Hello Paul,

I am no security expert—far from it.

I simply use the CSP recommended by testing tools, Google, and the like.

I am not questioning the security of your forum.

I've noted that there are just two primary scripts.
I'll insert the CSP directive there and keep you posted.

Author Paul
Lead Lead Developer
#9 · Posted: 16 Oct 2026 14:40
Frédéric:
I am no security expert—far from it.
This is what I was about. Do not modify scripts if you don't understand the nature of changes. That's the only thing I could recommend.

I know it's nowadays sort of fashion to rely on solutions and "advices" thrown by machine algorithms, and in many cases they are useful — but not always, the crap's given often is not even close to that.

Author Frédéric
Guest
#10 · Posted: 18 Oct 2026 18:59
Hello Paul,

Paul:
The primary PHP scripts are just index.php and bb_admin.php (or whatever it could be named).
I don't find bb_admin.php in my very old version.

What is the name in old versions ?

name with "admin", I have only : mf2pqcm_admin.php

Author Frédéric
Guest
#11 · Posted: 18 Oct 2026 21:54
Hello Paul,

Paul:
This is what I was about. Do not modify scripts if you don't understand the nature of changes. That's the only thing I could recommend.
Ok but what do you think about HTTP Observatory ?

They recommend to have a good CSP header.

script-src 'self' 'unsafe-inline';

It works but it's not very strong.

Better is ;

script-src 'self'; script-src-elem 'self' 'unsafe-inline';

I'll test it in the .htaccess.

Author tom322
Active Member
#12 · Posted: 19 Oct 2026 00:49
Instead of touching the .htaccess or PHP files, you can play to put something like this in the main_header.html's forum template:

<meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://www.youtube.com; img-src 'self' https: data:; object-src 'none'; base-uri 'none';">

Author Paul
Lead Lead Developer
#13 · Posted: 19 Oct 2026 16:41
Frédéric:
I don't find bb_admin.php in my very old version.What is the name in old versions ?
It's not about the version, but the security. As recommended, you have obviously renamed your admin file and its filename is stored in setup_options.php -> $bb_admin setting.

Frédéric:
Ok but what do you think about HTTP Observatory? They recommend to have a good CSP header.
If you mean the MDN tool, there miniBB website passes more tests than Google 😃 As many other services it's just a private service which gives its own recommendations. While not being associated with it, I couldn't give any comment.

Obviously it all could make sense if there's a way to make certain tests after it, making sure it all could some way protect your webiste from something exact.

tom322:
Instead of touching the .htaccess or PHP files, you can play to put something like this in the main_header.html's forum template
This is what I wouldn't recommend initially. I didn't try it on my own and not sure all javascript codes would work properly with this tag afterall.

Author Frédéric
Guest
#14 · Posted: 19 Oct 2026 21:50
Hello Paul and tom322,

tom322:
Instead of touching the .htaccess or PHP files, you can play to put something like this in the main_header.html's forum template:
Right. It is possible to do it this way.

Paul:
If you mean the MDN tool, there miniBB website passes more tests than Google 😃
Yes, I mean the MDN tool.
And I know that minibb is very secure.

Author Frédéric
Guest
#15 · Posted: 19 Oct 2026 21:52
As a guest can I edit last post ?
I don't see how to do it.

Page  Page 1 of 2 :  1  2  Next » 
The Other miniBB Support Forums / The Other /
 Primary miniBB scripts for CSP
Share Link Share Topic's Link
 Click this icon to move up to the quoted message

 ∅ ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

  
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Check out the Polls & Surveys add-on: organize surveys on miniBB-forums, collecting them in one place.


⇑