Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
42f9718
Update README.md
100HnoMeuNome Sep 7, 2020
4796977
Update README.md
100HnoMeuNome Sep 7, 2020
a9a8b58
Update README.md
100HnoMeuNome Sep 7, 2020
f756a7f
Update README.md
100HnoMeuNome Sep 7, 2020
9d9e0b4
Update README.md
100HnoMeuNome Sep 7, 2020
a7b07de
Update README.md
100HnoMeuNome Sep 7, 2020
0b30fea
Update README.md
100HnoMeuNome Sep 9, 2020
2ac8860
Update README.md
100HnoMeuNome Sep 9, 2020
004dda3
Update README.md
100HnoMeuNome Sep 9, 2020
742b678
Update README.md
100HnoMeuNome Sep 9, 2020
063e985
Update README.md
100HnoMeuNome Oct 28, 2020
f6029ba
Update README.md
100HnoMeuNome Oct 28, 2020
24f769d
Update README.md
100HnoMeuNome Oct 29, 2020
12bfdb1
Update README.md
100HnoMeuNome Jan 26, 2021
d315bd7
Update README.md
100HnoMeuNome Jan 26, 2021
7eadda7
Update README.md
100HnoMeuNome Jan 26, 2021
d2861cb
Update README.md
100HnoMeuNome Jan 26, 2021
bb61f68
Update README.md
100HnoMeuNome Jan 26, 2021
9db5df6
Update README.md
100HnoMeuNome Jan 26, 2021
be0e92b
Update README.md
100HnoMeuNome Jan 26, 2021
d5f5c72
Update README.md
100HnoMeuNome Jan 26, 2021
6aade1e
Update README.md
100HnoMeuNome Jan 26, 2021
a6fff08
Update README.md
100HnoMeuNome Jan 26, 2021
7ce7efa
Update README.md
100HnoMeuNome Jan 26, 2021
f2eb9ee
Update README.md
100HnoMeuNome Jan 27, 2021
5fd92f9
Update README.md
100HnoMeuNome Apr 19, 2021
c64fec2
Create config.yml
100HnoMeuNome Aug 2, 2021
1356fdf
Update config.yml
100HnoMeuNome Aug 2, 2021
7067e15
Update config.yml
100HnoMeuNome Aug 2, 2021
3bc6616
Update config.yml
100HnoMeuNome Aug 2, 2021
7c2229c
Update config.yml
100HnoMeuNome Aug 2, 2021
ef89ace
Update config.yml
100HnoMeuNome Aug 2, 2021
1dc61e8
Create static-analysis.datadog.yml
100HnoMeuNome Aug 3, 2023
ec794dd
Create datadog-static-analysis.yml
100HnoMeuNome Aug 3, 2023
01517e5
Update datadog-static-analysis.yml
100HnoMeuNome Aug 4, 2023
e7ea05b
Update datadog-static-analysis.yml
100HnoMeuNome Aug 4, 2023
c46825c
Update datadog-static-analysis.yml
100HnoMeuNome Aug 4, 2023
53a574e
Update datadog-static-analysis.yml
100HnoMeuNome Aug 4, 2023
31caac0
Update datadog-static-analysis.yml
100HnoMeuNome Aug 4, 2023
30c315e
Update datadog-static-analysis.yml
100HnoMeuNome Aug 8, 2023
d339823
Update static-analysis.datadog.yml
100HnoMeuNome Oct 2, 2023
f255b8d
Update datadog-static-analysis.yml
100HnoMeuNome Dec 26, 2023
eb1157a
Create datadog-sca.yml
100HnoMeuNome Jan 23, 2024
4839435
Update datadog-sca.yml
100HnoMeuNome Feb 7, 2024
7cc6681
Update datadog-static-analysis.yml
100HnoMeuNome Feb 16, 2024
04a540a
Update static-analysis.datadog.yml
100HnoMeuNome Jul 29, 2024
ce77630
Update datadog-static-analysis.yml
100HnoMeuNome Jul 29, 2024
3426d9c
Update requirements.txt
100HnoMeuNome Jul 29, 2024
ef8055b
Update datadog-static-analysis.yml
100HnoMeuNome Jul 29, 2024
db4000e
update dockerfile
100HnoMeuNome Sep 4, 2024
5b2dd9e
teste
100HnoMeuNome Sep 6, 2024
3a76682
Create config
100HnoMeuNome Apr 22, 2025
cf733d3
Update config
100HnoMeuNome Apr 22, 2025
0a9d13f
Update config
100HnoMeuNome Apr 22, 2025
eba5e7b
Update and rename config to config_dyna
100HnoMeuNome Apr 22, 2025
daa32ce
Create docker
100HnoMeuNome Apr 22, 2025
27d2202
[Datadog] Fix python-security/variable-sql-statement-injection violation
100HnoMeuNome Oct 13, 2025
a8350bd
Delete .github/workflows/datadog-sca.yml
100HnoMeuNome Oct 29, 2025
cdb1758
Delete .github/workflows/datadog-static-analysis.yml
100HnoMeuNome Oct 29, 2025
caff395
Add Dockerfile for multi-stage build and runtime
100HnoMeuNome Oct 29, 2025
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
11 changes: 11 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2.1
orbs:
snyk: snyk/snyk@1.0.1
jobs:
build:
docker:
- image: 'caf3ina/vulnerableimage'
steps:
- checkout
- run: pip3 install requirements.txt
- snyk/scan
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM python:3.8-slim-buster
FROM python:3.8
COPY . /headpage
WORKDIR /headpage
RUN pip3 install --upgrade pip && \
pip3 install --trusted-host pypi.python.org -r requirements.txt && \
./reset_db.sh
RUN pip3 install --no-cache-dir --upgrade pip && \
EXPOSE 8000
ENTRYPOINT ["python3", "src/manage.py","runserver","0.0.0.0:8000"]
52 changes: 34 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
# HeadPage
# What is the HeadPage?

A Simple and porpousely vulnerable django web-application for testing and learning
A Simple and porpousely vulnerable django web-application for testing and learning how to protect using the Trend Micro Application Security.

# What is the Cloud One Application Security?

Trend Micro Cloud One - Application Security provides runtime protection for containerized applications and serverless functions. When Application Security is properly deployed, threats to your web applications will be detected and protected against, minimizing your risk. Determined attackers are continuously running scanners against your site, creating malicious user accounts, fuzzing various elements, triggering exceptions, and attempting to run exploitation tools.

* More information here: https://cloudone.trendmicro.com/docs/application-security/
* Create a account in Cloud One https://cloudone.trendmicro.com/

![index](docs/index.png)
![User profile](docs/profile.png)

## Idea
## Running
The recommended way is using docker using the following commands to build and run the container.

* Create a social-media-like (HeadPage != Facebook) web application with a relatively small, and vulnerable, code base.
* Users create public profiles, upload files for public (such as photos)or private (such as pdfs) use and browse other users' profiles.
`$ yum install git -y`

## Running
The recommended way is using docker using the following commands to build and run the container
`$ git clone https://github.com/caf3ina/HeadPage.git`

`docker build --tag=headpage:latest .`
`$ cd HeadPage/`

`docker run -d --rm -p 8000:8000 --name headpage headpage:latest`
* Edit the following line on `src/headpage/settings.py` to serve HeadPage on all interfaces. This can be dangerous, if possible run inside a VM on Host-Only interface.

Otherwise, install the dependencies on `requirements.txt` and run the default django webserver and you'll be good to go.
`ALLOWED_HOSTS = ['*']`

## Allowing connections other than localhost
Create a file with name `trend_app_protect.ini` and put the information bellow.

Change the following line on `src/headpage/settings.py` to serve HeadPage on all interfaces. This can be dangerous, if possible run inside a VM on Host-Only interface.
`[trend_app_protect]`

`ALLOWED_HOSTS = ['*']`
`key = my-key`

`secret = my-secret`

## Why?
**Yes**
Get the key and secret from Cloud One Application Security console
https://cloudone.trendmicro.com/docs/application-security/python/#install-the-agent

`docker build --tag=headpage:latest .`

`docker run -d --rm -p 8000:8000 --name headpage headpage:latest`

## The site is ugly as sin!
**Yes** - Also, I'm not a web developer
* Open the url http://ip-address:8000/social/

## Main Vulnerabilities

Expand All @@ -43,9 +55,6 @@ Change the following line on `src/headpage/settings.py` to serve HeadPage on all
* The user's first/last name or username are not sanitized and are displayed on their profile.
* E.g. username: `<script>alert("!!")</script>`

### CSRF
* To be Implemented (?)

### Open Redirect
* When clicking the link to the login/register page from a previous page, the previous Page URL is sent as a Parameter for a redirection back to the previous page after loging in/registering. The redirection URL is not validated.
* E.g. 127.0.0.1:8000/social/login/?redirect=evilsite.url
Expand All @@ -64,3 +73,10 @@ Change the following line on `src/headpage/settings.py` to serve HeadPage on all
* Some static files are returned after GET requests `127.0.0.1:8000/social/static/?file=privacy.txt` The `file` in the GET is not properly validated/sanitized

![/etc/passwd leak](docs/path_traversal.png)

### Console Events

* Malicious Payload

![Block](https://user-images.githubusercontent.com/46326549/92649532-90319580-f2c1-11ea-9081-27214e5afdeb.jpg)
![app sec](https://user-images.githubusercontent.com/46326549/92649758-e3a3e380-f2c1-11ea-8e37-d78dcc0c7c10.jpg)
2 changes: 2 additions & 0 deletions config_dyna
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dt0s01.ST2EY72KQINMH574WMNVI7YN.G3DFPBEJYMODIDAEX454M7YWBUVEFOWKPRVMWFASS64NFH52PX6BNDVFFM572RZM

1 change: 1 addition & 0 deletions docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx
31 changes: 31 additions & 0 deletions dockerfilenew
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# --- STAGE 1: build all modules ---
FROM maven:3.9.7-eclipse-temurin-17 AS builder
WORKDIR /app

# 1) copia todo o código
COPY . .

# 2) instala o bancocentral-module no repositório local
RUN mvn -f bancocentral-module/pom.xml clean install -DskipTests

# 3) compila e empacota o pom raiz (que engloba auth, account, transaction, etc)
RUN mvn clean package -DskipTests

# --- STAGE 2: runtime com JRE Debian-slim multi-arch ---
FROM eclipse-temurin:17-jre
WORKDIR /app

# copia os jars prontos
COPY --from=builder /app/auth-module/target/auth-module-1.0-SNAPSHOT.jar auth-module.jar
COPY --from=builder /app/account-module/target/account-module-1.0-SNAPSHOT.jar account-module.jar
COPY --from=builder /app/integration-module/target/integration-module-1.0-SNAPSHOT.jar integration-module.jar
COPY --from=builder /app/notification-module/target/notification-module-1.0-SNAPSHOT.jar notification-module.jar
COPY --from=builder /app/transaction-module/target/transaction-module-1.0-SNAPSHOT.jar transaction-module.jar
COPY --from=builder /app/bancocentral-module/target/bancocentral-module-1.0-SNAPSHOT.jar bancocentral-module.jar

# script de startup
COPY start-all.sh .
RUN chmod +x start-all.sh

EXPOSE 8081 8082 8083 8084 8085 8088 8089
CMD ["./start-all.sh"]
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Django==2.2.12
trend-app-protect #Optional
2 changes: 1 addition & 1 deletion src/headpage/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*']


# Application definition
Expand Down
6 changes: 3 additions & 3 deletions src/social/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def register(request):
password=get_password_hash(request.POST.get('password'))
try:
# +++ VULNERABLE TO SQL INJECTION +++
curs.executescript(
"INSERT INTO social_user ('username','password','first_name','last_name') VALUES ('{}','{}','{}','{}')".format(
username,password,first_name,last_name)
curs.execute(
"INSERT INTO social_user (username, password, first_name, last_name) VALUES (%s, %s, %s, %s)",
[username, password, first_name, last_name]
)
#+++ VULNERABLE TO UNVALIDATED REDIRECTS +++
return redirect(url_to_redirect)
Expand Down