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

OOZIE-3719 : Denial of Service (ReDoS) Vulnerability #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions core/src/main/java/org/apache/oozie/CoordinatorEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,14 @@ public void streamLog(String jobId, String logRetrievalScope, String logRetrieva
// Use set implementation that maintains order or elements to achieve reproducibility:
Set<String> actionSet = new LinkedHashSet<String>();
String[] list = logRetrievalScope.split(",");
LOG.debug("Value for the retrieval type of JobId : " + jobId);
int continuousRangeSum = 0;
for (String s : list) {
s = s.trim();
if (s.contains("-")) {
String[] range = s.split("-");
if (range.length != 2) {
throw new CommandException(ErrorCode.E0302, "format is wrong for action's range '" + s
+ "'");
throw new CommandException(ErrorCode.E0302, "format is wrong for action's range '" + s + "', an example of correct format is 1-5");
}
int start;
int end;
Expand All @@ -341,7 +342,15 @@ public void streamLog(String jobId, String logRetrievalScope, String logRetrieva
if (start > end) {
throw new CommandException(ErrorCode.E0302, "format is wrong for action's range '" + s + "'");
}

LOG.debug("Start and end actionIds are : " + start + " to " + end);
continuousRangeSum = continuousRangeSum + (end - start + 1);
if (continuousRangeSum > maxNumActionsForLog) {
throw new CommandException(ErrorCode.E0302, "action's range: " + continuousRangeSum + " is too large than allowed: " + maxNumActionsForLog);
}

for (int i = start; i <= end; i++) {
LOG.debug("Adding to actionSet.");
actionSet.add(jobId + "@" + i);
}
}
Expand Down
19 changes: 19 additions & 0 deletions core/src/main/java/org/apache/oozie/coord/CoordUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@


public class CoordUtils {
private static final XLog LOG = XLog.getLog(CoordUtils.class);
public static final String HADOOP_USER = "user.name";

public final static String COORD_ACTIONS_LOG_MAX_COUNT = "oozie.coord.actions.log.max.count";
private final static int COORD_ACTIONS_LOG_MAX_COUNT_DEFAULT = 50;
private static int maxNumActionsForLog;
static {
maxNumActionsForLog = Services.get().getConf().getInt(COORD_ACTIONS_LOG_MAX_COUNT, COORD_ACTIONS_LOG_MAX_COUNT_DEFAULT);
LOG.info("maxNumActionsForLog set to = " + maxNumActionsForLog);
}

public static String getDoneFlag(Element doneFlagElement) {
if (doneFlagElement != null) {
return doneFlagElement.getTextTrim();
Expand Down Expand Up @@ -198,6 +207,8 @@ public static Set<String> getActionsIds(String jobId, String scope) throws Comma

Set<String> actions = new LinkedHashSet<String>();
String[] list = scope.split(",");
LOG.debug("Value for the retrieval type of JobId : " + jobId);
int continuousRangeSum = 0;
for (String s : list) {
s = s.trim();
// An action range is specified with two actions separated by '-'
Expand All @@ -221,11 +232,19 @@ public static Set<String> getActionsIds(String jobId, String scope) throws Comma
} catch (NumberFormatException ne) {
throw new CommandException(ErrorCode.E0302, "could not parse " + range[1].trim() + "into an integer", ne);
}
LOG.debug("Start and end actionIds are : " + start + " to " + end);
continuousRangeSum = continuousRangeSum + (end - start + 1);
LOG.debug("continuousRangeSum = " + continuousRangeSum);
LOG.debug("maxNumActionsForLog = " + maxNumActionsForLog);
if (continuousRangeSum > maxNumActionsForLog) {
throw new CommandException(ErrorCode.E0302, "action's range: " + continuousRangeSum + " is too large than allowed: " + maxNumActionsForLog);
}
if (start > end) {
throw new CommandException(ErrorCode.E0302, "format is wrong for action's range '" + s + "', starting action"
+ "number of the range should be less than ending action number, an example will be 1-4");
}
// Add the actionIds
LOG.debug("Adding to actionSet.");
for (int i = start; i <= end; i++) {
actions.add(jobId + "@" + i);
}
Expand Down