Giter Club home page Giter Club logo

Comments (13)

szepeviktor avatar szepeviktor commented on May 24, 2024 1
ENV CONTENT_SECURITY_POLICY='{ "some": "JSON" }'

💡 Then use jq to turn it into a HTTP header.

from docker-php.

jaydrogers avatar jaydrogers commented on May 24, 2024

@danpastori You should review this above. ☝ī¸

I'll probably pull this in the next release if you are cool with it.

from docker-php.

danpastori avatar danpastori commented on May 24, 2024

@jaydrogers Makes sense to remove it. Looks like it's kind of a "false security" that can be circumnavigated through other attempts. We've implemented a secure CSP on our Docker containers right?

from docker-php.

jaydrogers avatar jaydrogers commented on May 24, 2024

We did, but then we removed it 😁

# Configure Content Security Policy
# UPDATE - September 2020: Commenting this out until we grasp better security requirements
#add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;

from docker-php.

jaydrogers avatar jaydrogers commented on May 24, 2024

Adding more comments from /u/Tontonsb:

I just read the discussion on your PR. Yeah, CSP is the only solution, but unfourtunately it's complex and very project specific. And on legacy projects you're just sometimes left with default-src https: data: 'unsafe-inline' 'unsafe-eval'... Actually, not "legacy" projects, but normal projects that are not made with CSP in mind.

We might want to remove CSP all together and let users manage it on their own, or come up with a way where it can be easily managed with an environment variable 🤔

It gets very project specific and we will need really good documentation on this.

from docker-php.

danpastori avatar danpastori commented on May 24, 2024

Just thinking out loud. How hard would it be to add some sort of custom .env type file that gets compiled into docker that's set on a per-app basis? For example (I'll try my best at yml):

Headers
     CSP
          "default-src"
          'self'
          http:

And then you just flatten that array to be the header that gets added. I know when working with Electron and CapacitorJS, you have to have this down to a science.

from docker-php.

danpastori avatar danpastori commented on May 24, 2024

As an appending to ☝ī¸, are there any other settings that would be useful to store in an env that are app specific? Maybe you already have this.

from docker-php.

jaydrogers avatar jaydrogers commented on May 24, 2024

Good news is, there is no YAML in this repo. 🤓

ENVs are set like this:

# 🚨 IMPORTANT: Change the SSMTP relay server if you want emails to work
# For example, you can override this with the "docker run" command:
# `docker run -e SSMTP_RELAY_SERVER=smtp serversideup/php8.0-fpm`
ENV MSMTP_RELAY_SERVER_HOSTNAME="mailhog" \
MSMTP_RELAY_SERVER_PORT="1025" \
PHP_POOL_NAME="www" \
PHP_PM_CONTROL=ondemand \
PHP_PM_MAX_CHILDREN="20" \
PHP_PM_START_SERVERS="2" \
PHP_PM_MIN_SPARE_SERVERS="1" \
PHP_PM_MAX_SPARE_SERVERS="3"

So that means it would look like this:

ENV CONTENT_SECURITY_POLICY="\"default-src \'self\' http: https: data: blob: \'unsafe-inline\'\" always\;"

☝ī¸ But as you can see, I don't even know if this example will work.

We would have to escape all of this stuff in bash, which might get really messy. Not sure how NGINX would take this.

Thoughts?

from docker-php.

danpastori avatar danpastori commented on May 24, 2024

I'm thinking about providing an optional "App Specific" env. Would that make sense? Some sort of config file that you could customize and build into the docker image to overwrite values, or add values on an app specific basis?

It could be completely out of scope since I can set some of the CSP stuff in HTML. Just thinking.

from docker-php.

jaydrogers avatar jaydrogers commented on May 24, 2024

That could definitely work. The only negative I see from controlling it from the app level for the ENV would be we need to figure that out for both application types:

  1. Laravel
  2. WordPress

Putting the ENV at the docker layer will allow us to set an ENV within Docker which could then be easily customized for any type of app.

from docker-php.

jaydrogers avatar jaydrogers commented on May 24, 2024

I wonder if @szepeviktor would have any thoughts on this? ☝ī¸

from docker-php.

szepeviktor avatar szepeviktor commented on May 24, 2024

kÊp

This speaks for itself. ~100% of browser makers do not support it.

I do not understand the technical details.
As far as I see security is made from very many steps. There is no way to protect a website without human 👨‍đŸ”Ŧ expertise and continuous presence: an expert webmaster.

from docker-php.

jaydrogers avatar jaydrogers commented on May 24, 2024

Thanks @szepeviktor!

Specifically, I was wondering if there is a sensible way to set the content security policy as an ENV without it looking like garbage with all of the escaping. See this comment for more details: #31 (comment)

from docker-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.