Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default paranoia settings break CRS #339

Merged
merged 4 commits into from
Feb 27, 2025
Merged
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
39 changes: 39 additions & 0 deletions .github/workflows/verifyimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
env:
# sha256sum format: <hash><space><format (space for text)><file name>
MODSECURITY_RECOMMENDED: "ccff8ba1f12428b34ff41960d8bf773dd9f62b9a7c77755247a027cb01896d4f modsecurity.conf-recommended"
GO_FTW_VERSION: '1.3.0'

jobs:
prepare:
Expand Down Expand Up @@ -107,3 +108,41 @@ jobs:
grep -q "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS" headers.txt
grep -q "Access-Control-Allow-Headers: *" headers.txt
fi

- name: Checkout CRS
uses: actions/checkout@v4
with:
fetch-depth: 1
repository: coreruleset/coreruleset
path: crs
- name: "Install go-ftw"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd crs
gh release download -R coreruleset/go-ftw "v${{ env.GO_FTW_VERSION }}" \
-p "ftw_${{ env.GO_FTW_VERSION }}_linux_amd64.tar.gz" -O - | tar -xzvf - ftw
- name: Patch CRS compose file to use verification image
run: |
sed -i \
's#image: owasp/modsecurity-crs:${{ contains(matrix.target, 'apache') && 'apache' || 'nginx' }}.*#image: ${{ matrix.target }}-verification#' \
crs/tests/docker-compose.yml
- name: Run CRS tests for ${{ matrix.target }}
run: |
cd crs
modsec_version="${{ contains(matrix.target, 'apache') && 'modsec2-apache' || 'modsec3-nginx' }}"
backend="${{ contains(matrix.target, 'apache') && 'httpd' || 'nginx' }}"
mkdir -p "tests/logs/${modsec_version}/{nginx,apache2}"
docker compose -f ./tests/docker-compose.yml up -d "${modsec_version}"
docker compose -f ./tests/docker-compose.yml logs
if ! [ "$(docker inspect ${modsec_version} --format='{{.State.Running}}')" = "true" ]; then
echo "Web server failed to start. Aborting."
exit 1
fi

./ftw check -d tests/regression/tests
./ftw run \
-d tests/regression/tests \
--log-file "tests/logs/${modsec_version}/error.log" \
--overrides "tests/regression/${backend}-overrides.yaml" \
--show-failures-only
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ You can achieve the same results just by getting any version you want, and using
git clone https://github.com/coreruleset/coreruleset.git myrules
cd myrules
git checkout ac2a0d1
docker run -p 8080:8080 -ti -e PARANOIA=4 -v rules:/opt/owasp-crs/rules:ro --rm owasp/modsecurity-crs
docker run -p 8080:8080 -ti -e BLOCKING_PARANOIA=4 -v rules:/opt/owasp-crs/rules:ro --rm owasp/modsecurity-crs
```

## Quick reference
Expand Down Expand Up @@ -412,8 +412,8 @@ docker run \
-e MODSEC_AUDIT_LOG=/var/log/modsec_audit.log \
-e LOGLEVEL=warn \
-e ERRORLOG=/var/log/modsec_error.log \
-e PARANOIA=1 \
-e EXECUTING_PARANOIA=2 \
-e BLOCKING_PARANOIA=2 \
-e DETECTION_PARANOIA=2 \
-e ENFORCE_BODYPROC_URLENCODED=1 \
-e ANOMALY_INBOUND=10 \
-e ANOMALY_OUTBOUND=5 \
Expand Down
1 change: 0 additions & 1 deletion apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ ENV \
TIMEOUT=60 \
WORKER_CONNECTIONS=400 \
# CRS specific variables
PARANOIA=1 \
ANOMALY_INBOUND=5 \
ANOMALY_OUTBOUND=4 \
BLOCKING_PARANOIA=1
Expand Down
1 change: 0 additions & 1 deletion apache/Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ ENV \
TIMEOUT=60 \
WORKER_CONNECTIONS=400 \
# CRS specific variables
PARANOIA=1 \
ANOMALY_INBOUND=5 \
ANOMALY_OUTBOUND=4 \
BLOCKING_PARANOIA=1
Expand Down
36 changes: 18 additions & 18 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ target "apache" {
lua_modules = join(" ", lua-modules-debian)
tag_base = "apache"
},
{
name = "alpine"
dockerfile = "apache/Dockerfile-alpine"
image = "docker-image://httpd:${httpd-version}-alpine"
lua_modules = join(" ", lua-modules-alpine)
tag_base = "apache-alpine"
}
# {
# name = "alpine"
# dockerfile = "apache/Dockerfile-alpine"
# image = "docker-image://httpd:${httpd-version}-alpine"
# lua_modules = join(" ", lua-modules-alpine)
# tag_base = "apache-alpine"
# }
]
}

Expand Down Expand Up @@ -159,23 +159,23 @@ target "nginx" {
lua_modules = join(" ", lua-modules-debian)
tag_base = "nginx"
},
{
name = "alpine"
dockerfile = "nginx/Dockerfile-alpine"
image = "docker-image://nginxinc/nginx-unprivileged:${nginx-version}-alpine"
lua_modules = join(" ", lua-modules-alpine)
tag_base = "nginx-alpine"
}
# {
# name = "alpine"
# dockerfile = "nginx/Dockerfile-alpine"
# image = "docker-image://nginxinc/nginx-unprivileged:${nginx-version}-alpine"
# lua_modules = join(" ", lua-modules-alpine)
# tag_base = "nginx-alpine"
# }
],
read-only-fs = [
{
name = "writable"
read-only = "false"
},
{
name = "read-only"
read-only = "true"
}
# {
# name = "read-only"
# read-only = "true"
# }
]
}
inherits = ["platforms-base"]
Expand Down
1 change: 0 additions & 1 deletion nginx/Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ ENV \
SSL_VERIFY=off \
WORKER_CONNECTIONS=1024 \
# CRS specific variables
PARANOIA=1 \
ANOMALY_INBOUND=5 \
ANOMALY_OUTBOUND=4 \
BLOCKING_PARANOIA=1
Expand Down
2 changes: 1 addition & 1 deletion src/opt/modsecurity/configure-rules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ false|RESTRICTED_HEADERS_BASIC|900250|restricted_headers_basic|/if/
false|RESTRICTED_HEADERS_EXTENDED|900255|restricted_headers_extended|/x-some-header/
false|MAX_NUM_ARGS|900300|max_num_args|100
false|ARG_NAME_LENGTH|900310|arg_name_length|200
false|ARG_LENGTH|900230|arg_length|300
false|ARG_LENGTH|900320|arg_length|300
false|TOTAL_ARG_LENGTH|900330|total_arg_length|400
false|MAX_FILE_SIZE|900340|max_file_size|500
false|COMBINED_FILE_SIZES|900350|combined_file_sizes|600
Expand Down