This application contains intentional security vulnerabilities for demonstrating GitHub Advanced Security features.
DO NOT use this code in production! These vulnerabilities are intentionally included for educational and demonstration purposes only.
The VulnerableController.cs contains multiple code-level vulnerabilities that CodeQL will detect:
- Location:
SearchShipsmethod - Issue: Direct string concatenation in SQL query
- Risk: Attacker can manipulate database queries
- Location:
PingServermethod - Issue: Unvalidated user input passed to shell command
- Risk: Arbitrary command execution on server
- Location:
DownloadFilemethod - Issue: No validation of file paths
- Risk: Access to unauthorized files via
../sequences
- Location:
Welcomemethod - Issue: Unencoded user input in HTML response
- Risk: Script injection in user's browser
- Location:
DeserializeDatamethod - Issue: TypeNameHandling.All allows arbitrary type instantiation
- Risk: Remote code execution
- Location: Class constants
- Issue: Passwords and API keys in source code
- Risk: Credential exposure in version control
- Location:
GenerateTokenandEncryptDatamethods - Issue: Non-cryptographic random and Base64 "encryption"
- Risk: Predictable tokens and weak data protection
- Location:
TriggerErrormethod - Issue: Exposing stack traces and sensitive error details
- Risk: Leaking internal system information
- Location:
DeleteAllShipsmethod - Issue: No authentication checks on critical operations
- Risk: Unauthorized access to sensitive operations
- Location:
LdapSearchmethod - Issue: Unvalidated LDAP filter construction
- Risk: LDAP query manipulation
- Location:
ParseXmlmethod - Issue: XML parser without XXE protection
- Risk: Information disclosure, SSRF, DoS
The project includes known vulnerable package versions:
| Package | Vulnerable Version | Known CVEs |
|---|---|---|
| Newtonsoft.Json | 9.0.1 | GHSA-5crp-9r3c-p9vr (High) |
| Npgsql | 4.1.2 | GHSA-x9vc-6hfv-hg8c (High) |
| SharpZipLib | 1.2.0 | GHSA-m22m-h4rf-pwq3 (High), GHSA-mm6g-mmq6-53ff (Moderate) |
| System.Text.Encodings.Web | 4.5.0 | GHSA-ghhp-997w-qr28 (Critical) |
| BouncyCastle | 1.8.5 | Multiple known vulnerabilities |
Hard-coded secrets that will be detected:
- Database passwords
- API keys
- Connection strings with credentials
-
Enable GHAS for your repository:
- Go to Settings → Security & analysis
- Enable "GitHub Advanced Security"
-
Enable Dependabot alerts:
- Enable "Dependabot alerts"
- Enable "Dependabot security updates"
-
Enable Code scanning:
- Enable "Code scanning"
- The CodeQL workflow is already configured in
.github/workflows/codeql.yml
-
Enable Secret scanning:
- Enable "Secret scanning"
- Enable "Push protection" (optional)
All these features are available for free!
After pushing this code:
- Security tab → View all security alerts
- Dependabot alerts → See vulnerable dependencies
- Code scanning alerts → See code vulnerabilities detected by CodeQL
- Secret scanning alerts → See detected secrets (if any match patterns)
To fix these issues:
- Remove or quarantine the
VulnerableController.csfile - Update all package versions to their latest secure versions
- Remove hard-coded credentials and use secure configuration
- Implement proper input validation and parameterized queries
- Review and remediate all CodeQL findings