Skip to content

Commit

Permalink
[MINOR] Fix some potential security leak issue
Browse files Browse the repository at this point in the history
Fix two potential security leak issue based on the security code scan:

1. Add file name checking code in `RSCDriverBootstrapper`'s main method argument to avoid malicious file.
2. Avoid dumping exception stack to output.

CC yanboliang zjffdu please help to review.

Author: jerryshao <[email protected]>

Closes apache#22 from jerryshao/security-issue.
  • Loading branch information
jerryshao committed Jul 27, 2017
1 parent 087adb6 commit dcd29a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rsc/src/main/java/org/apache/livy/rsc/RSCClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void onSuccess(Void unused) throws Exception {

@Override
public void onFailure(Throwable error) throws Exception {
error.printStackTrace();
LOG.error("RPC error.", error);
promise.tryFailure(error);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.livy.rsc.driver;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
Expand Down Expand Up @@ -47,7 +48,13 @@ public static void main(String[] args) throws Exception {

case 1:
props = new Properties();
Reader r = new InputStreamReader(new FileInputStream(args[0]), UTF_8);
File propertyFile = new File(args[0]);
String fileName = propertyFile.getName();
if (!fileName.startsWith("livyConf") && fileName.endsWith("properties")) {
throw new IllegalArgumentException("File name " + fileName + "is not a legal file name.");
}

Reader r = new InputStreamReader(new FileInputStream(propertyFile), UTF_8);
try {
props.load(r);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class InteractiveSessionServlet(
Created(new JobStatus(jobId, JobHandle.State.SENT, null, null))
} catch {
case e: Throwable =>
e.printStackTrace()
throw e
}
}
Expand Down

0 comments on commit dcd29a0

Please sign in to comment.