Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion common/src/main/java/com/genexus/IHttpContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ public interface IHttpContext {
boolean isHttpContextNull();
boolean isHttpContextWeb();


String getContextPath();
}
15 changes: 11 additions & 4 deletions java/src/main/java/com/genexus/GxImageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;

import com.genexus.db.driver.ResourceAccessControlList;
import com.genexus.util.GxFileInfoSourceType;
Expand All @@ -22,13 +23,19 @@ private static InputStream getInputStream(String filePathOrUrl) throws IOExcepti

private static BufferedImage createBufferedImageFromURI(String filePathOrUrl) throws IOException
{
try (InputStream is = getGXFile(filePathOrUrl).getStream()) {
IHttpContext httpContext = com.genexus.ModelContext.getModelContext().getHttpContext();
InputStream is = null;
try{
if (filePathOrUrl.toLowerCase().startsWith("http://") || filePathOrUrl.toLowerCase().startsWith("https://") ||
(httpContext.isHttpContextWeb() && filePathOrUrl.startsWith(httpContext.getContextPath())))
is = new URL(GXDbFile.pathToUrl( filePathOrUrl, httpContext)).openStream();

Check failure

Code scanning / CodeQL

Server-side request forgery

Potential server-side request forgery due to a [user-provided value](1). Potential server-side request forgery due to a [user-provided value](2).
else
is = getGXFile(filePathOrUrl).getStream();
return ImageIO.read(is);
}
catch (IOException e) {
} catch (IOException e) {
log.error("Failed to read image stream: " + filePathOrUrl);
throw e;
}
} finally {is.close();}
}

private static GXFile getGXFile(String filePathOrUrl) {
Expand Down