yeswehack/vulnerable-code-snippets

Twitter vulnerable snippets

PHP

1,184

405 commits

updated Feb 11, 2026

See the code

README

YWH Logo Vulnerable Code Snippets

Vulnerable code snippet (Vsnippet) banner YesWeHack Github repository

Vulnerabilities | Programming languages | Run a vulnerable code snippet | Installation | Update

YesWeHack present code snippets containing several different vulnerabilities to practice your code analysis in a safe dockerized envoriment. The vulnerable code snippets are suitable for all skill levels.

~ New vulnerable code snippet at Twitter @yeswehack every Friday! πŸ—’

If you want to see something special or if you just have an idea about a vulnerable code snippet, feel free to create a "New Issue" where you explain your idea, no idea is stupid.


⚠️ Be aware

Be sure to run this in a secure environment, as the code is vulnerable and is intended to be used for learning code analysis! By default, all vulnerable code snippets contain a docker setup that isolates the code from your host system and make it safe to run (read more in the section : "Run a vulnerable code snippet").

Twitter (X) posts

A Collection of all vulnerable code snippets posted on our Twitter πŸ“‚

IDVulnerabilityDescription
πŸ“œ#1SQLi & XSSBackslash filter collide
πŸ“œ#2Improper file access & XSSInvalid char and regex verificaion
πŸ“œ#3Log Forging injection, Path traversal & Code injectionPoor filter and improper include() handling
πŸ“œ#4XSSInvalid user input filter
πŸ“œ#5SSRF & Broken authorizationTrusted user input and client IP from header
πŸ“œ#6SSTIMixed input format
πŸ“œ#7SQLiUse of invalid variable within statement
πŸ“œ#8CSRFNo CSRF token included
πŸ“œ#9Open RedirectInvalid regex handler
πŸ“œ#10DOM XSSBackend filter collide with client side JavaScript
πŸ“œ#11CORSMisconfigured Access-Control-Allow header
πŸ“œ#12CSRF/ClickJackingGET request CSRF with insecure delete process / ClickJacking - X-Frame-Options set in HTML meta tag
πŸ“œ#13Path Traversal/Unrestricted File UploadPoor Path Traversal and file upload protection results in a code injection
πŸ“œ#14DOSIncorrect operator handler in "for loop"
πŸ“œ#15Weak Password Recovery Mechanism for Forgotten PasswordWeak hash for password recovery
πŸ“œ#16IDORinsecure if statement leads to improper access control
πŸ“œ#17Insecure deserializationExecute trusted user input inside pickle function loads()
πŸ“œ#18Path TraversalImproper user validation of filename
πŸ“œ#19Open RedirectInvalid handling of user-controlled input "location.hash"
πŸ“œ#20SQL injectionInvalid use of function replace(), The char is only replaced once
πŸ“œ#21PostMessage DOM XSSNo origin validation, leading to PostMessage DOM XSS
πŸ“œ#22XSS/OpenRedirectThe filter protection does not filter all special characters that can be used to exploit the vulnerabilities
πŸ“œ#23Buffer overflowTake user's STDIN input with the gets() function without checking the buffer size
πŸ“œ#24SQL injectionIncorrect use of the PHP function addslashes()
πŸ“œ#25XSS - CSP bypassNo validation of user input along with insecure handling of nonce
πŸ“œ#26Path TraversalThe filter provided by the PHP function "preg_replace()" is limited to filtering only the first 10 characters
πŸ“œ#27Web Cache PoisoningThe HTTP header Referer is reflected in the cached response body without being filtered
πŸ“œ#28Business logic vulnerabilityAn attacker can withdraw negative amounts to increase the overall balance of their account
πŸ“œ#29IDORAn attacker can gain access to sensitive data from other users by performing a Forced browsing attack
πŸ“œ#30Insecure deserializationUse of a dangerous function (exec) that can be controlled by the user, resulting in an RCE
πŸ“œ#31LFINo proper character escaping or filter verification. The include() function executes all PHP code in the given file, no matter the file extension, resulting in code injection
πŸ“œ#32Format injection!Format a string containing values provided by the client, resulting in a format injection
πŸ“œ#33SQL injection (second order)All SQL queries use prepared statements except the last one. This statement extracts a value from the database that was once controlled by the user and adds it to the SQL query, leading to an SQL injection (second order)
πŸ“œ#34Regular expression Denial of Service (ReDoS)Poorly configured regex pattern used to filter user-controlled input
πŸ“œ#35XSSTrusted user input in GET parameter
πŸ“œ#36Unrestricted File UploadInsufficient validation of the file extension of the uploaded file and missed validation of the file content
πŸ“œ#37SSRFInsecure handling of the proxy header X-Forwarded-Host and cURL leading to a full SSRF
πŸ“œ#38Code injectionThe user can write customised content to a selected file which is then launched on the vulnerable system
πŸ“œ#39LFIExploitation of an LFI make it possible to run the tool pearcmd resulting in a remote code execution
πŸ“œ#40Unrestricted File UploadThe php3 extension can be used to execute php code due to the configuration in the Apache proxy.
πŸ“œ#41Command injectionInvalid usage of escapeshellcmd lead to a command injection vulnerability
πŸ“œ#42Command injectionNo validation of user input is performed, leading to a command injection vulnerability
πŸ“œ#43SSTIImproper usage of templte engine leading to a SSTI which result in an RCE

Vulnerabilities

Programming languages

Also included


Run a vulnerable code snippet

In each vulnerable code snippet (Vsnippet) folder there is a docker-compose.yml file. To start a Vsnippet in an isolated docker environment simply run the following command:

docker compose up --build

or

docker-compose up --build

Installation

git clone https://github.com/yeswehack/vulnerable-code-snippets.git

Update

To get the latest vulnerable code snippets, run:

git pull

~ H4v3 y0u f0und th3 E4st3r 3gg y3t? πŸ‡πŸͺΊ

For questions, help or if you have discovered a problem with the code. Contact us on Twitter: @yeswehack πŸ“¬

bugbounty
code
code-analyze
example-code
owasp
snippets
vulnerable
web-application
websecurity
worst-practices

yeswehack/vulnerable-code-snippets

Twitter vulnerable snippets

PHP

1,184

405 commits

updated Feb 11, 2026

See the code

README

YWH Logo Vulnerable Code Snippets

Vulnerable code snippet (Vsnippet) banner YesWeHack Github repository

Vulnerabilities | Programming languages | Run a vulnerable code snippet | Installation | Update

YesWeHack present code snippets containing several different vulnerabilities to practice your code analysis in a safe dockerized envoriment. The vulnerable code snippets are suitable for all skill levels.

~ New vulnerable code snippet at Twitter @yeswehack every Friday! πŸ—’

If you want to see something special or if you just have an idea about a vulnerable code snippet, feel free to create a "New Issue" where you explain your idea, no idea is stupid.


⚠️ Be aware

Be sure to run this in a secure environment, as the code is vulnerable and is intended to be used for learning code analysis! By default, all vulnerable code snippets contain a docker setup that isolates the code from your host system and make it safe to run (read more in the section : "Run a vulnerable code snippet").

Twitter (X) posts

A Collection of all vulnerable code snippets posted on our Twitter πŸ“‚

IDVulnerabilityDescription
πŸ“œ#1SQLi & XSSBackslash filter collide
πŸ“œ#2Improper file access & XSSInvalid char and regex verificaion
πŸ“œ#3Log Forging injection, Path traversal & Code injectionPoor filter and improper include() handling
πŸ“œ#4XSSInvalid user input filter
πŸ“œ#5SSRF & Broken authorizationTrusted user input and client IP from header
πŸ“œ#6SSTIMixed input format
πŸ“œ#7SQLiUse of invalid variable within statement
πŸ“œ#8CSRFNo CSRF token included
πŸ“œ#9Open RedirectInvalid regex handler
πŸ“œ#10DOM XSSBackend filter collide with client side JavaScript
πŸ“œ#11CORSMisconfigured Access-Control-Allow header
πŸ“œ#12CSRF/ClickJackingGET request CSRF with insecure delete process / ClickJacking - X-Frame-Options set in HTML meta tag
πŸ“œ#13Path Traversal/Unrestricted File UploadPoor Path Traversal and file upload protection results in a code injection
πŸ“œ#14DOSIncorrect operator handler in "for loop"
πŸ“œ#15Weak Password Recovery Mechanism for Forgotten PasswordWeak hash for password recovery
πŸ“œ#16IDORinsecure if statement leads to improper access control
πŸ“œ#17Insecure deserializationExecute trusted user input inside pickle function loads()
πŸ“œ#18Path TraversalImproper user validation of filename
πŸ“œ#19Open RedirectInvalid handling of user-controlled input "location.hash"
πŸ“œ#20SQL injectionInvalid use of function replace(), The char is only replaced once
πŸ“œ#21PostMessage DOM XSSNo origin validation, leading to PostMessage DOM XSS
πŸ“œ#22XSS/OpenRedirectThe filter protection does not filter all special characters that can be used to exploit the vulnerabilities
πŸ“œ#23Buffer overflowTake user's STDIN input with the gets() function without checking the buffer size
πŸ“œ#24SQL injectionIncorrect use of the PHP function addslashes()
πŸ“œ#25XSS - CSP bypassNo validation of user input along with insecure handling of nonce
πŸ“œ#26Path TraversalThe filter provided by the PHP function "preg_replace()" is limited to filtering only the first 10 characters
πŸ“œ#27Web Cache PoisoningThe HTTP header Referer is reflected in the cached response body without being filtered
πŸ“œ#28Business logic vulnerabilityAn attacker can withdraw negative amounts to increase the overall balance of their account
πŸ“œ#29IDORAn attacker can gain access to sensitive data from other users by performing a Forced browsing attack
πŸ“œ#30Insecure deserializationUse of a dangerous function (exec) that can be controlled by the user, resulting in an RCE
πŸ“œ#31LFINo proper character escaping or filter verification. The include() function executes all PHP code in the given file, no matter the file extension, resulting in code injection
πŸ“œ#32Format injection!Format a string containing values provided by the client, resulting in a format injection
πŸ“œ#33SQL injection (second order)All SQL queries use prepared statements except the last one. This statement extracts a value from the database that was once controlled by the user and adds it to the SQL query, leading to an SQL injection (second order)
πŸ“œ#34Regular expression Denial of Service (ReDoS)Poorly configured regex pattern used to filter user-controlled input
πŸ“œ#35XSSTrusted user input in GET parameter
πŸ“œ#36Unrestricted File UploadInsufficient validation of the file extension of the uploaded file and missed validation of the file content
πŸ“œ#37SSRFInsecure handling of the proxy header X-Forwarded-Host and cURL leading to a full SSRF
πŸ“œ#38Code injectionThe user can write customised content to a selected file which is then launched on the vulnerable system
πŸ“œ#39LFIExploitation of an LFI make it possible to run the tool pearcmd resulting in a remote code execution
πŸ“œ#40Unrestricted File UploadThe php3 extension can be used to execute php code due to the configuration in the Apache proxy.
πŸ“œ#41Command injectionInvalid usage of escapeshellcmd lead to a command injection vulnerability
πŸ“œ#42Command injectionNo validation of user input is performed, leading to a command injection vulnerability
πŸ“œ#43SSTIImproper usage of templte engine leading to a SSTI which result in an RCE

Vulnerabilities

Programming languages

Also included


Run a vulnerable code snippet

In each vulnerable code snippet (Vsnippet) folder there is a docker-compose.yml file. To start a Vsnippet in an isolated docker environment simply run the following command:

docker compose up --build

or

docker-compose up --build

Installation

git clone https://github.com/yeswehack/vulnerable-code-snippets.git

Update

To get the latest vulnerable code snippets, run:

git pull

~ H4v3 y0u f0und th3 E4st3r 3gg y3t? πŸ‡πŸͺΊ

For questions, help or if you have discovered a problem with the code. Contact us on Twitter: @yeswehack πŸ“¬

bugbounty
code
code-analyze
example-code
owasp
snippets
vulnerable
web-application
websecurity
worst-practices

Significant stargazers

g0tmi1k

3,562 followers Β· starred Nov 2022

Raz Luvaton

156 followers Β· starred Nov 2022

Abdulmalik Salawu

114 followers Β· starred Jun 2025

Chad Bentz

42 followers Β· starred Nov 2022