Skip to content

Commit ab511cf

Browse files
Add security warnings to sample credentials and create SECURITY.md
Co-authored-by: thomasturrell <1552612+thomasturrell@users.noreply.github.com>
1 parent c1dfe24 commit ab511cf

31 files changed

Lines changed: 368 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,12 @@ public ResponseEntity<Collection<UUID>> postStatements(
489489

490490
```
491491

492+
## Security
493+
494+
For security best practices and credential management guidelines, see [SECURITY.md](SECURITY.md).
495+
496+
**Important**: The sample applications contain hardcoded credentials for demonstration purposes only. Never use these credentials in production. See [SECURITY.md](SECURITY.md) for secure configuration approaches.
497+
492498
## Contributing
493499

494500
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for:

SECURITY.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Security Policy
2+
3+
## Reporting a Vulnerability
4+
5+
If you discover a security vulnerability in xapi-java, please report it to the project maintainers. Please do not create a public GitHub issue for security vulnerabilities.
6+
7+
## Security Best Practices
8+
9+
### Credential Management
10+
11+
The xAPI client library supports multiple authentication methods for connecting to Learning Record Stores (LRS):
12+
13+
#### Configuration Properties
14+
15+
The library accepts the following configuration properties:
16+
17+
- `xapi.client.username` - Username for basic authentication
18+
- `xapi.client.password` - Password for basic authentication
19+
- `xapi.client.authorization` - Full authorization header value (takes precedence over username/password)
20+
21+
#### Security Recommendations
22+
23+
**DO NOT** hardcode credentials in application.properties files:
24+
25+
```properties
26+
# ❌ NEVER DO THIS IN PRODUCTION
27+
xapi.client.username = admin
28+
xapi.client.password = password
29+
```
30+
31+
**DO** use one of these secure approaches:
32+
33+
1. **Environment Variables** (Recommended)
34+
```properties
35+
xapi.client.username = ${XAPI_USERNAME}
36+
xapi.client.password = ${XAPI_PASSWORD}
37+
```
38+
39+
2. **External Configuration**
40+
- Use Spring Cloud Config Server
41+
- Use Kubernetes Secrets
42+
- Use AWS Secrets Manager, Azure Key Vault, or similar services
43+
44+
3. **Authorization Header with Tokens**
45+
```properties
46+
xapi.client.authorization = ${XAPI_AUTH_TOKEN}
47+
```
48+
49+
4. **System Properties**
50+
```bash
51+
java -jar myapp.jar \
52+
--xapi.client.username=${XAPI_USERNAME} \
53+
--xapi.client.password=${XAPI_PASSWORD}
54+
```
55+
56+
### Sample Applications
57+
58+
The sample applications in the `samples/` directory contain hardcoded credentials for demonstration purposes only:
59+
60+
```properties
61+
xapi.client.username = admin
62+
xapi.client.password = password
63+
```
64+
65+
**These are example credentials and MUST NOT be used in production environments.**
66+
67+
Before running samples against a real LRS:
68+
1. Copy the `application.properties` file
69+
2. Replace the credentials with your actual LRS credentials
70+
3. Add the properties file to `.gitignore` to prevent accidental commits
71+
4. Or use environment variables to override the properties
72+
73+
### HTTPS Usage
74+
75+
The xAPI client library uses Spring WebClient which supports HTTPS by default. Always use HTTPS URLs when connecting to production LRS endpoints:
76+
77+
```properties
78+
# ✅ Good - HTTPS
79+
xapi.client.baseUrl = https://lrs.example.com/xapi/
80+
81+
# ❌ Bad - HTTP (only for local development)
82+
xapi.client.baseUrl = http://localhost:8080/xapi/
83+
```
84+
85+
### Dependency Security
86+
87+
This project uses:
88+
- Dependabot for automated dependency updates
89+
- GitHub Actions for CI/CD security scanning
90+
- SonarCloud for static code analysis
91+
92+
Regular dependency updates help maintain security. Review and merge Dependabot PRs promptly.
93+
94+
## Security Hotspots Review
95+
96+
### Hardcoded Credentials (Addressed)
97+
98+
**Issue**: Sample application.properties files contained hardcoded credentials without security warnings.
99+
100+
**Resolution**: Added prominent security warnings to all sample configuration files explaining that credentials are for demo purposes only and providing guidance on secure credential management.
101+
102+
**Status**: ✅ Resolved - Demo credentials are clearly marked with security warnings
103+
104+
### Additional Findings
105+
106+
No additional security hotspots requiring immediate action were identified during the review. The codebase follows security best practices:
107+
108+
- Uses Spring Security's built-in authentication mechanisms
109+
- Employs HTTPS for external communications
110+
- Validates all xAPI data against the specification
111+
- Uses parameterized queries (no SQL injection vulnerabilities)
112+
- No use of insecure cryptographic functions
113+
- No dynamic class loading or unsafe deserialization
114+
115+
## Security Scan Results
116+
117+
This repository is regularly scanned using:
118+
- **SonarCloud**: For code quality and security analysis
119+
- **GitHub CodeQL**: For security vulnerability detection
120+
- **Dependabot**: For dependency vulnerability alerts
121+
122+
## Supported Versions
123+
124+
Security updates are provided for the latest stable release. Users are encouraged to upgrade to the latest version to receive security fixes.
125+
126+
## Additional Resources
127+
128+
- [xAPI Specification Security Considerations](https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-About.md#def-security)
129+
- [Spring Boot Security Documentation](https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.security)
130+
- [OWASP Top 10](https://owasp.org/www-project-top-ten/)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SECURITY WARNING: These credentials are FOR DEMO/TESTING PURPOSES ONLY.
2+
# DO NOT use these credentials in production environments.
3+
# For production use:
4+
# - Store credentials in environment variables or secure configuration management
5+
# - Use the xapi.client.authorization property with a secure token
6+
# - Consider using Spring Cloud Config or similar secure configuration solutions
7+
# - Never commit real credentials to version control
8+
19
xapi.client.username = admin
210
xapi.client.password = password
311
xapi.client.baseUrl = https://example.com/xapi/

0 commit comments

Comments
 (0)