]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Limits tamper check find to depth 1, as only files at the first level could be run
authorTrenton Holmes <holmes.trenton@gmail.com>
Tue, 25 Oct 2022 16:40:01 +0000 (09:40 -0700)
committerTrenton H <797416+stumpylog@users.noreply.github.com>
Tue, 8 Nov 2022 16:52:01 +0000 (08:52 -0800)
docker/docker-prepare.sh

index 92c9d1f1585ab9cf1df63cca3e1f76c2913c8591..18b5e8815bafcd923953af59894cde75aee930a8 100755 (executable)
@@ -97,12 +97,12 @@ custom_container_init() {
        # Don't run files which are owned by anyone except root
        # Don't run files which are writeable by others
        if [ -d "${custom_script_dir}" ]; then
-               if [ -n "$(/usr/bin/find "${custom_script_dir}" ! -user root)" ]; then
+               if [ -n "$(/usr/bin/find "${custom_script_dir}" -maxdepth 1 ! -user root)" ]; then
                        echo "**** Potential tampering with custom scripts detected ****"
                        echo "**** The folder '${custom_script_dir}' must be owned by root ****"
                        return 0
                fi
-               if [ -n "$(/usr/bin/find "${custom_script_dir}" -perm -o+w)" ]; then
+               if [ -n "$(/usr/bin/find "${custom_script_dir}" -maxdepth 1 -perm -o+w)" ]; then
                        echo "**** The folder '${custom_script_dir}' or some of contents have write permissions for others, which is a security risk. ****"
                        echo "**** Please review the permissions and their contents to make sure they are owned by root, and can only be modified by root. ****"
                        return 0