Fix chameleon persona implementation — HTML corruption, missing robots.txt, compose profiles#58
Open
Divyateja2709 wants to merge 85 commits intoOWASP:masterfrom
Open
Fix chameleon persona implementation — HTML corruption, missing robots.txt, compose profiles#58Divyateja2709 wants to merge 85 commits intoOWASP:masterfrom
Divyateja2709 wants to merge 85 commits intoOWASP:masterfrom
Conversation
Added optional CRS update logic and improved logging for background processes.
Added initial README.md for CRS Auto Update script with planned features and assumptions.
Removed comment about Sidekick code generation.
Added logging and process management for Apache and Filebeat.
Updated the script to enforce SHA256 checksum format and added timeout options for curl and wget commands.
Updated filebeat configuration path to absolute path.
Updated Dockerfile to include TARGETARCH argument and modified file paths.
Added headers to prevent HTTP_PROXY leakage and set authentication headers.
Add a test script to verify the existence of bundled CRS paths and includes in the Docker container.
This script tests the successful update of the CRS within a Docker container, ensuring that the configuration remains valid and usable after the update.
Refactor test script for CRS update to use unique identifiers and validate fixture installation.
This script tests the behavior of the CRS update when the updater is disabled, ensuring that the status reflects 'skipped' and that the bundled CRS files remain intact.
Add a test script to verify fallback behavior during CRS update download failure.
This script tests the fallback behavior of the CRS updater when the SHA256 checksum does not match the expected value. It verifies that the bundled CRS remains unchanged and that the correct status is recorded.
This script tests the behavior of the CRS update process when a lock is held by another instance. It verifies that the update is skipped and the bundled CRS remains intact.
…docker-compose.yml to remove profiles for both, and add script execution in modsec_entry.sh for persona swapping.
…cript execution flow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @adrianwinckles,
Following on from the chameleon persona PRs (PR8-PR11), this PR addresses several issues that were preventing the implementation from working reliably end to end.
The chameleon persona system works by running WordPress and Drupal as separate nginx containers behind the ModSecurity WAF reverse proxy. When Shodan detects the honeypot, shodan_watcher.py calls swap_persona.sh to stop the current persona container and start a different one. The WAF always proxies to persona-app network alias so the swap is transparent.
HTML files had trailing garbage after
Both personas/wordpress/html/index.html and personas/drupal/html/index.html had markdown documentation text accidentally pasted after the closing tag. This produces invalid HTML which could cause unexpected behavior with scanners that parse HTML to identify applications.
2. robots.txt returning 404 for WordPress and Drupal personas
The nginx configs for both WordPress and Drupal personas had location = /robots.txt { try_files $uri =404; } but the actual robots.txt files didn't exist on disk. Real WordPress and Drupal sites always expose a robots.txt — scanners check this as part of fingerprinting. A 404 here immediately weakens the disguise.
3. Persona containers never created so swap always failed
persona-wordpress and persona-drupal had Compose profiles set. This meant on a normal docker compose up these containers were never created. When swap_persona.sh tried to run docker start persona-wordpress it would fail because the container simply didn't exist. Removed the profiles so all persona containers are created on startup. Added a call to swap_persona.sh generic at the start of modsec_entry.sh so only one persona is active at a time from the beginning.
No CI
Added a GitHub Actions workflow that triggers on any PR touching honeytraps/waf_modsec/, builds the Docker image, and runs run_tests.sh automatically.
to check
bash
cd honeytraps/waf_modsec
docker compose up --build
--- Generic persona
curl -i http://localhost:9091/
---Expect: 200, generic content
--- Swap to WordPress
bash ./scripts/swap_persona.sh wordpress
curl -i http://localhost:9091/
--- Expect: X-Generator: WordPress 5.8.1
-- WordPress robots.txt
curl http://localhost:9091/robots.txt
---Expect: WordPress style robots.txt with /wp-admin/ entries
--- Swap to Drupal
bash ./scripts/swap_persona.sh drupal
curl -i http://localhost:9091/
--- Expect: X-Generator: Drupal 7
Run all tests
bash run_tests.sh
Update — CI workflow fix:
The initial GitHub Actions workflow ran the full run_tests.sh which builds the Docker image and spins up containers. This worked locally but timed out in GitHub Actions due to the large base image size (owasp/modsecurity-crs:apache) and multi-container test setup.
Updated the workflow to:
Use docker/setup-buildx-action for better Docker support in CI
Build the WAF image explicitly before running tests
Run only the single-container tests that work reliably in GitHub Actions (test_crs_*.sh, test_shodan_watcher_disabled.sh)
Skip the multi-container swap tests which require docker compose networking — these are verified locally as shown in the verification steps above
The full test suite including persona swap tests still runs correctly locally via bash run_tests.sh.