Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sandboxed URL creation to prevent SSRF attacks #7

Closed
Changes from all commits
Commits
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
17 changes: 13 additions & 4 deletions demo/pom.xml
Original file line number Diff line number Diff line change
@@ -68,7 +68,8 @@
<version.jboss.bom.eap>6.3.2.GA</version.jboss.bom.eap>
<version.jboss.bom.wfk>2.7.0-redhat-1</version.jboss.bom.wfk>
<buildhelper.plugin.version>1.7</buildhelper.plugin.version>
</properties>
<versions.java-security-toolkit>1.2.1</versions.java-security-toolkit>
</properties>

<dependencyManagement>
<dependencies>
@@ -103,7 +104,12 @@
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
<dependency>
<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
<version>${versions.java-security-toolkit}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
@@ -238,8 +244,11 @@
<artifactId>resteasy-jaxrs</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>
<dependency>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library holds security tools for protecting Java API calls.

License: MIT ✅ | Open source ✅ | More facts

<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
</dependency>
</dependencies>

<build>
<!-- Maven will append the version to the finalName (which is the
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jboss.examples.ticketmonster.service;

import io.github.pixee.security.HostValidator;
import io.github.pixee.security.Urls;
import static org.jboss.examples.ticketmonster.model.MediaType.IMAGE;

import java.io.BufferedInputStream;
@@ -121,7 +123,7 @@ private MediaPath createPath(MediaItem mediaItem) {
private boolean checkResourceAvailable(MediaItem mediaItem) {
URL url = null;
try {
url = new URL(mediaItem.getUrl());
url = Urls.create(mediaItem.getUrl(), Urls.HTTP_PROTOCOLS, HostValidator.DENY_COMMON_INFRASTRUCTURE_TARGETS);
} catch (MalformedURLException e) {
}

@@ -170,7 +172,7 @@ private MediaPath createCachedMedia(String url, MediaType mediaType) {
if (!alreadyCached(cachedFileName)) {
URL _url = null;
try {
_url = new URL(url);
_url = Urls.create(url, Urls.HTTP_PROTOCOLS, HostValidator.DENY_COMMON_INFRASTRUCTURE_TARGETS);
} catch (MalformedURLException e) {
throw new IllegalStateException("Error reading URL " + url);
}