Skip to content
Open
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
3 changes: 3 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ RUN apt-get update -y \
&& mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini \
&& rm -rf /var/lib/apt/lists/*

COPY apache-deny.conf /etc/apache2/conf-enabled/deny.conf
RUN apache2ctl configtest

# Get Dolibarr
RUN curl -fLSs https://github.com/Dolibarr/dolibarr/archive/${DOLI_VERSION}.tar.gz |\
tar -C /tmp -xz && \
Expand Down
65 changes: 65 additions & 0 deletions apache-conf-enabled/deny-certificates.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Denying different certificate files
<FilesMatch "/\.cer">
Require all denied
</FilesMatch>

<FilesMatch "/\.crt">
Require all denied
</FilesMatch>

<FilesMatch "/\.cert">
Require all denied
</FilesMatch>

<FilesMatch "/\.pem">
Require all denied
</FilesMatch>

<FilesMatch "/\.der">
Require all denied
</FilesMatch>

<FilesMatch "/\.key">
Require all denied
</FilesMatch>

<FilesMatch "/\.keystore">
Require all denied
</FilesMatch>

<FilesMatch "/\.jks">
Require all denied
</FilesMatch>

<FilesMatch "/\.p12">
Require all denied
</FilesMatch>

<FilesMatch "/\.pcks">
Require all denied
</FilesMatch>

<FilesMatch "/\.ca-bundle">
Require all denied
</FilesMatch>

<FilesMatch "/\.p7b">
Require all denied
</FilesMatch>

<FilesMatch "/\.p7c">
Require all denied
</FilesMatch>

<FilesMatch "/\.p7s">
Require all denied
</FilesMatch>

<FilesMatch "/\.pfx">
Require all denied
</FilesMatch>

<FilesMatch "/\.p8">
Require all denied
</FilesMatch>

25 changes: 25 additions & 0 deletions apache-conf-enabled/deny-compressed-files.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Deny various compression files
<FilesMatch "/\.gz">
Require all denied
</FilesMatch>

<FilesMatch "/\.tgz">
Require all denied
</FilesMatch>

<FilesMatch "/\.tar">
Require all denied
</FilesMatch>

<FilesMatch "/\.zip">
Require all denied
</FilesMatch>

<FilesMatch "/\.bz2">
Require all denied
</FilesMatch>

<FilesMatch "/\.rar">
Require all denied
</FilesMatch>

9 changes: 9 additions & 0 deletions apache-conf-enabled/deny-csv.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denying MS Office, Libre Office, or even CSV might be a bad idea, as most companies rely on those types of documents

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cibero42

yes, but I do no think these files are served directly through Apache as static files, I think they are served as files through PHP - because else you can not have Dolibarr access control to these files.

How do we figure out? Well, we test it, and we test it all the places that we download files in Dolibarr.

Examples

EXPORT  /document.php?modulepart=export&file=export_adherent_1.csv&entity=1
DOCUMENTS    /document.php?modulepart=ecm&attachment=1&file=Manuals%2Finvitational_brutto_liste.ods
ORDER PDF      /document.php?hashp=********************

Claim all files in Dolibarr are downloaded through document.php not through apache, and thus we can easily without issues ban any other file than .php and .html files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Jon,

Thanks for the explanation! If that's the case, it's better to include other MS Office and LibreOffice formats, no?

If you prefer, I can try to find a comprehensive list for you and post here...

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Denying Spreadsheet files
<FilesMatch "/\.csv">
Require all denied
</FilesMatch>

<FilesMatch "/\.xls">
Require all denied
</FilesMatch>

5 changes: 5 additions & 0 deletions apache-conf-enabled/deny-doc.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denying MS Office, Libre Office, or even CSV might be a bad idea, as most companies rely on those types of documents

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Denying word files
<FilesMatch "/\.doc">
Require all denied
</FilesMatch>

9 changes: 9 additions & 0 deletions apache-conf-enabled/deny-dolibarr-conf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deny dolibarr configuration file
<DirectoryMatch "/conf/">
Require all denied
</DirectoryMatch>

<FilesMatch "/conf\.php">
Require all denied
</FilesMatch>

9 changes: 9 additions & 0 deletions apache-conf-enabled/deny-dolibarr-langs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deny Dolibarr language files
<DirectoryMatch "/langs/">
Require all denied
</DirectoryMatch>

<FilesMatch "/\.lang">
Require all denied
</FilesMatch>

5 changes: 5 additions & 0 deletions apache-conf-enabled/deny-dotfiles.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Denying . files
<FilesMatch "/^\.">
Require all denied
</FilesMatch>

9 changes: 9 additions & 0 deletions apache-conf-enabled/deny-git.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deny git repositories and files
<DirectoryMatch "/\.git">
Require all denied
</DirectoryMatch>

<FilesMatch "/^\.git">
Require all denied
</FilesMatch>

5 changes: 5 additions & 0 deletions apache-conf-enabled/deny-json.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Deny JSON files
<FilesMatch "/\.json">
Require all denied
</FilesMatch>

5 changes: 5 additions & 0 deletions apache-conf-enabled/deny-sql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Denying Database files
<FilesMatch "/\.sql">
Require all denied
</FilesMatch>

5 changes: 5 additions & 0 deletions apache-conf-enabled/deny-svn.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Denying subversion because it was mentioned in the security.conf file that came with the container image
<DirectoryMatch "/\.svn">
Require all denied
</DirectoryMatch>

5 changes: 5 additions & 0 deletions apache-conf-enabled/deny-xml.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Denying XML files
<FilesMatch "/\.xml">
Require all denied
</FilesMatch>

5 changes: 5 additions & 0 deletions apache-conf-enabled/deny-yml.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Denying Yaml files
<FilesMatch "/\.yml">
Require all denied
</FilesMatch>

3 changes: 3 additions & 0 deletions images/15.0.3-php7.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ RUN apt-get update -y \
&& mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini \
&& rm -rf /var/lib/apt/lists/*

COPY apache-deny.conf /etc/apache2/conf-enabled/deny.conf
RUN apache2ctl configtest

# Get Dolibarr
RUN curl -fLSs https://github.com/Dolibarr/dolibarr/archive/${DOLI_VERSION}.tar.gz |\
tar -C /tmp -xz && \
Expand Down
161 changes: 161 additions & 0 deletions images/15.0.3-php7.4/apache-deny.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Denying different certificate files
<FilesMatch "/\.cer">
Require all denied
</FilesMatch>

<FilesMatch "/\.crt">
Require all denied
</FilesMatch>

<FilesMatch "/\.cert">
Require all denied
</FilesMatch>

<FilesMatch "/\.pem">
Require all denied
</FilesMatch>

<FilesMatch "/\.der">
Require all denied
</FilesMatch>

<FilesMatch "/\.key">
Require all denied
</FilesMatch>

<FilesMatch "/\.keystore">
Require all denied
</FilesMatch>

<FilesMatch "/\.jks">
Require all denied
</FilesMatch>

<FilesMatch "/\.p12">
Require all denied
</FilesMatch>

<FilesMatch "/\.pcks">
Require all denied
</FilesMatch>

<FilesMatch "/\.ca-bundle">
Require all denied
</FilesMatch>

<FilesMatch "/\.p7b">
Require all denied
</FilesMatch>

<FilesMatch "/\.p7c">
Require all denied
</FilesMatch>

<FilesMatch "/\.p7s">
Require all denied
</FilesMatch>

<FilesMatch "/\.pfx">
Require all denied
</FilesMatch>

<FilesMatch "/\.p8">
Require all denied
</FilesMatch>

# Deny various compression files
<FilesMatch "/\.gz">
Require all denied
</FilesMatch>

<FilesMatch "/\.tgz">
Require all denied
</FilesMatch>

<FilesMatch "/\.tar">
Require all denied
</FilesMatch>

<FilesMatch "/\.zip">
Require all denied
</FilesMatch>

<FilesMatch "/\.bz2">
Require all denied
</FilesMatch>

<FilesMatch "/\.rar">
Require all denied
</FilesMatch>

# Denying Spreadsheet files
<FilesMatch "/\.csv">
Require all denied
</FilesMatch>

<FilesMatch "/\.xls">
Require all denied
</FilesMatch>

# Denying word files
<FilesMatch "/\.doc">
Require all denied
</FilesMatch>

# Deny dolibarr configuration file
<DirectoryMatch "/conf/">
Require all denied
</DirectoryMatch>

<FilesMatch "/conf\.php">
Require all denied
</FilesMatch>

# Deny Dolibarr language files
<DirectoryMatch "/langs/">
Require all denied
</DirectoryMatch>

<FilesMatch "/\.lang">
Require all denied
</FilesMatch>

# Denying . files
<FilesMatch "/^\.">
Require all denied
</FilesMatch>

# Deny git repositories and files
<DirectoryMatch "/\.git">
Require all denied
</DirectoryMatch>

<FilesMatch "/^\.git">
Require all denied
</FilesMatch>

# Deny JSON files
<FilesMatch "/\.json">
Require all denied
</FilesMatch>

# Denying Database files
<FilesMatch "/\.sql">
Require all denied
</FilesMatch>

# Denying subversion because it was mentioned in the security.conf file that came with the container image
<DirectoryMatch "/\.svn">
Require all denied
</DirectoryMatch>

# Denying XML files
<FilesMatch "/\.xml">
Require all denied
</FilesMatch>

# Denying Yaml files
<FilesMatch "/\.yml">
Require all denied
</FilesMatch>

3 changes: 3 additions & 0 deletions images/16.0.5-php8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ RUN apt-get update -y \
&& mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini \
&& rm -rf /var/lib/apt/lists/*

COPY apache-deny.conf /etc/apache2/conf-enabled/deny.conf
RUN apache2ctl configtest

# Get Dolibarr
RUN curl -fLSs https://github.com/Dolibarr/dolibarr/archive/${DOLI_VERSION}.tar.gz |\
tar -C /tmp -xz && \
Expand Down
Loading