Security Issue - HIGH Priority
Description
The NexusClient and Credentials classes do not validate or sanitize repository names and URLs before constructing HTTP requests. This could lead to URL injection attacks or malformed requests.
Locations
src/main/java/org/flossware/jnexus/NexusClient.java lines 157-163
src/main/java/org/flossware/jnexus/Credentials.java line 156
Evidence
// No validation of repository parameter
String url = baseUrl + "/service/rest/v1/components?repository=" + repository;
// No URL format validation
if (url == null || url.isBlank()) {
throw new IllegalStateException("Nexus URL not configured...");
}
Security Impact
- Potential for URL injection attacks
- Malformed URLs could cause unexpected behavior
- No sanitization of user input before HTTP requests
- Could expose internal network information
Attack Scenarios
- Repository name with special characters:
repo&malicious=param
- Repository name with path traversal:
../../admin
- Invalid URL formats leading to crashes or information disclosure
Recommendations
- Validate repository names against allowed character set (alphanumeric, dash, underscore)
- Validate URL format using URI parsing
- URL-encode repository names before concatenation
- Add input sanitization at service layer
- Reject URLs with suspicious patterns
Implementation
private void validateRepository(String repository) {
if (repository == null || repository.isBlank()) {
throw new IllegalArgumentException("Repository cannot be null or blank");
}
if (!repository.matches("[a-zA-Z0-9_-]+")) {
throw new IllegalArgumentException("Repository contains invalid characters");
}
}
private void validateUrl(String url) {
try {
URI uri = URI.create(url);
if (!uri.getScheme().equals("https") && !uri.getScheme().equals("http")) {
throw new IllegalArgumentException("URL must use HTTP or HTTPS");
}
} catch (Exception e) {
throw new IllegalArgumentException("Invalid URL format", e);
}
}
Security Issue - HIGH Priority
Description
The NexusClient and Credentials classes do not validate or sanitize repository names and URLs before constructing HTTP requests. This could lead to URL injection attacks or malformed requests.
Locations
src/main/java/org/flossware/jnexus/NexusClient.javalines 157-163src/main/java/org/flossware/jnexus/Credentials.javaline 156Evidence
Security Impact
Attack Scenarios
repo&malicious=param../../adminRecommendations
Implementation