proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/BCELUtil.java
BCELUtil
getNumArgumentsIncludingObjectInstance
class BCELUtil { public static final String INVOKEDYNAMIC_GENERIC_CLASSNAME = Object.class.getName(); /** * Caching class inheritance. */ private static Map<String, Set<String>> superMap = new WeakHashMap<>(); public static String getSlashedClassName(ConstantPoolGen cpg, FieldOrMethod obj) {...
String signature = obj.getSignature(cpg); int count = 1; if ((obj.getOpcode() == Const.INVOKESTATIC) || (obj.getOpcode() == Const.INVOKEDYNAMIC)) { count = 0; } for (int i = 0; i < signature.length(); i++) { switch (signature.charAt(i)) { ...
683
315
998
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/DangerousPermissionCombination.java
DangerousPermissionCombination
reportBug
class DangerousPermissionCombination extends OpcodeStackDetector { private BugReporter bugReporter; public DangerousPermissionCombination(BugReporter bugReporter) { this.bugReporter = bugReporter; } private void reportBug(String permission, String target) {<FILL_FUNCTION_BODY>} @Override...
BugInstance bug = new BugInstance(this, "DANGEROUS_PERMISSION_COMBINATION", NORMAL_PRIORITY) .addClassAndMethod(this).addString(permission).addString(target).addSourceLine(this); bugReporter.reportBug(bug);
342
79
421
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/FindSecBugsGlobalConfig.java
FindSecBugsGlobalConfig
loadFromSystem
class FindSecBugsGlobalConfig { private static final FindSecBugsGlobalConfig instance = new FindSecBugsGlobalConfig(); private String findSecBugsVersion = "1.6.0"; private boolean debugPrintInstructionVisited = false; private boolean debugPrintInvocationVisited = false; private boolean debugTaintS...
String value = System.getenv(key); if (value == null) { // Environment variables containing dots are difficult to setup in // bash. Thus also accept underscores instead of dots. value = System.getenv(key.replace('.', '_')); } value = SystemProperties....
1,315
109
1,424
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/HttpResponseSplittingDetector.java
HttpResponseSplittingDetector
getPriority
class HttpResponseSplittingDetector extends BasicInjectionDetector { public HttpResponseSplittingDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("response-splitting.txt", "HTTP_RESPONSE_SPLITTING"); } @Override protected int getPriority(Taint taint) {<FI...
boolean newLineSafe = taint.hasOneTag(Taint.Tag.CR_ENCODED, Taint.Tag.LF_ENCODED); if (!taint.isSafe() && newLineSafe || taint.hasTag(Taint.Tag.URL_ENCODED)) { return Priorities.IGNORE_PRIORITY; } else if (taint.isTainted()) { return Priorities.NORMAL_PRIORITY; }...
111
169
280
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/ImproperHandlingUnicodeDetector.java
ImproperHandlingUnicodeDetector
sawOpcode
class ImproperHandlingUnicodeDetector extends OpcodeStackDetector { private String IMPROPER_UNICODE_TYPE = "IMPROPER_UNICODE"; private BugReporter bugReporter; public ImproperHandlingUnicodeDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } private void reportBug() { ...
//printOpCode(seen); // ImproperHandlingUnicodeDetector: [0398] invokestatic java/text/Normalizer.normalize (Ljava/lang/CharSequence;Ljava/text/Normalizer$Form;)Ljava/lang/String; if (seen == Const.INVOKESTATIC && getClassConstantOperand().equals("java/text/Normalizer") ...
578
556
1,134
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/ModificationAfterValidationDetector.java
ModificationAfterValidationDetector
sawOpcode
class ModificationAfterValidationDetector extends OpcodeStackDetector { Set<OpcodeStack.Item> validated = new HashSet<OpcodeStack.Item>(); private BugReporter bugReporter; public ModificationAfterValidationDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override ...
if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("java/util/regex/Pattern") && getNameConstantOperand().equals("matcher")) { validated.add(stack.getStackItem(0)); } else if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("java/lang/String"...
230
148
378
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/NormalizationAfterValidationDetector.java
NormalizationAfterValidationDetector
sawOpcode
class NormalizationAfterValidationDetector extends OpcodeStackDetector { Set<OpcodeStack.Item> validated = new HashSet<OpcodeStack.Item>(); private BugReporter bugReporter; public NormalizationAfterValidationDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override ...
if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("java/util/regex/Pattern") && getNameConstantOperand().equals("matcher")) { validated.add(stack.getStackItem(0)); } else if (seen == Const.INVOKESTATIC && getClassConstantOperand().equals("java/text/Normaliz...
232
142
374
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/PermissiveCORSDetector.java
PermissiveCORSDetector
getPriorityFromTaintFrame
class PermissiveCORSDetector extends BasicInjectionDetector { private static final String PERMISSIVE_CORS = "PERMISSIVE_CORS"; private static final String HTTP_SERVLET_RESPONSE_CLASS = "javax.servlet.http.HttpServletResponse"; private static final String HEADER_KEY = "Access-Control-Allow-Origin"; pri...
// Get the value of the Access-Control-Allow-Origin parameter (Second argument from setHeader(2nd,1rst)) Taint headerKeyTaint = fact.getStackValue(1); if (!(HEADER_KEY.equalsIgnoreCase(headerKeyTaint.getConstantValue()))) { //Ignore unknown/dynamic header name return Priorities.IGNO...
500
318
818
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/PredictableRandomDetector.java
PredictableRandomDetector
sawOpcode
class PredictableRandomDetector extends OpcodeStackDetector { private static final String PREDICTABLE_RANDOM_TYPE = "PREDICTABLE_RANDOM"; private static final String PREDICTABLE_RANDOM_SCALA_TYPE = "PREDICTABLE_RANDOM_SCALA"; //Static method call to next method can be differentiate from instance calls ...
// printOpCode(seen); if (seen == Const.INVOKESPECIAL && getClassConstantOperand().equals("java/util/Random") && getNameConstantOperand().equals("<init>")) { reportBug("java.util.Random", PREDICTABLE_RANDOM_TYPE); } else if (seen == Const.INVOKESTATIC && getClassC...
715
771
1,486
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/ReDosDetector.java
ReDosDetector
sawOpcode
class ReDosDetector extends OpcodeStackDetector { private static final String REDOS_TYPE = "REDOS"; private static final InvokeMatcherBuilder PATTERN_COMPILE = invokeInstruction().atClass("java/util/regex/Pattern") .atMethod("compile").withArgs("(Ljava/lang/String;)Ljava/util/regex/Pattern;"); ...
//printOpCode(seen); //IMPORTANT: Both API are regroup in the same condition because they both have one input string parameter. if (seen == Const.INVOKESTATIC && PATTERN_COMPILE.matches(this) || seen == Const.INVOKEVIRTUAL && STRING_MATCHES.matches(this)) { Opcode...
222
358
580
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/RedosAnnotationDetector.java
RedosAnnotationDetector
visitClassContext
class RedosAnnotationDetector implements Detector { private static final String REDOS_TYPE = "REDOS"; private static final String REGEX_ANNOTATION_TYPES = "Ljavax/validation/constraints/Pattern;"; private BugReporter bugReporter; public RedosAnnotationDetector(BugReporter bugReporter) { this...
JavaClass javaClass = classContext.getJavaClass(); field : for (Field f : javaClass.getFields()) { for (AnnotationEntry ae : f.getAnnotationEntries()) { if (REGEX_ANNOTATION_TYPES.equals(ae.getAnnotationType())) { ElementValuePair[] values = ae.getElem...
156
301
457
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/RegexRedosAnalyzer.java
RegexRedosAnalyzer
recurAnalyseRegex
class RegexRedosAnalyzer { private static final char[] OPENING_CHAR = {'(', '['}; private static final char[] CLOSING_CHAR = {')', ']'}; private static final char[] PLUS_CHAR = {'+', '*', '?'}; private boolean vulnerable = false; public boolean isVulnerable() { return vulnerable; }...
// print(level, "level = " + level); if (level == 2) { vulnerable = true; return 0; } // print(level, "Analysing " + regex.substring(0, startPosition + 1)); boolean openingMode = false; for (int i = startPosition; i >= 0; i--) { // p...
452
326
778
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/StrutsValidatorFormDetector.java
StrutsValidatorFormDetector
visitClassContext
class StrutsValidatorFormDetector implements Detector { private static final String STRUTS_FORM_VALIDATION_TYPE = "STRUTS_FORM_VALIDATION"; private BugReporter bugReporter; public StrutsValidatorFormDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override publi...
JavaClass javaClass = classContext.getJavaClass(); boolean isActionForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.action.ActionForm"); boolean isValidatorForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.validator.ValidatorForm"); boolean isDynaValidatorForm ...
136
417
553
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/WeakFilenameUtilsMethodDetector.java
WeakFilenameUtilsMethodDetector
sawOpcode
class WeakFilenameUtilsMethodDetector extends OpcodeStackDetector { private static final String WEAK_FILENAMEUTILS_TYPE = "WEAK_FILENAMEUTILS"; private BugReporter bugReporter; private static final InvokeMatcherBuilder FILENAMEUTILS_NULL_METHOD = invokeInstruction().atClass("org/apache/commons/io/Filenam...
if (seen == Const.INVOKESTATIC && FILENAMEUTILS_NULL_METHOD.matches(this)) { bugReporter.reportBug(new BugInstance(this, WEAK_FILENAMEUTILS_TYPE, Priorities.LOW_PRIORITY) // .addClass(this).addMethod(this).addSourceLine(this) .addString(getNameConstantOpera...
186
106
292
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/android/BroadcastDetector.java
BroadcastDetector
sawOpcode
class BroadcastDetector extends OpcodeStackDetector { private static final String ANDROID_BROADCAST_TYPE = "ANDROID_BROADCAST"; private BugReporter bugReporter; public BroadcastDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int se...
//printOpCode(seen); if (seen == Const.INVOKEVIRTUAL && ( getNameConstantOperand().equals("sendBroadcast") || getNameConstantOperand().equals("sendBroadcastAsUser") || getNameConstantOperand().equals("sendOrderedBroadcast") ||...
118
303
421
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/android/ExternalFileAccessDetector.java
ExternalFileAccessDetector
sawOpcode
class ExternalFileAccessDetector extends OpcodeStackDetector { private static final String ANDROID_EXTERNAL_FILE_ACCESS_TYPE = "ANDROID_EXTERNAL_FILE_ACCESS"; private BugReporter bugReporter; public ExternalFileAccessDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @O...
//printOpCode(seen); // getClassConstantOperand().equals("java/net/Socket") if (seen == Const.INVOKEVIRTUAL && ( //List of method mark as external file access getNameConstantOperand().equals("getExternalCacheDir") || getNameConstantOperand().equals("getExternal...
129
345
474
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/android/GeolocationDetector.java
GeolocationDetector
visitClassContext
class GeolocationDetector implements Detector { private static final boolean DEBUG = false; private static final String ANDROID_GEOLOCATION_TYPE = "ANDROID_GEOLOCATION"; private final BugReporter bugReporter; public GeolocationDetector(BugReporter bugReporter) { this.bugReporter = bugReporter;...
JavaClass javaClass = classContext.getJavaClass(); //The class extends WebChromeClient boolean isWebChromeClient = InterfaceUtils.isSubtype(javaClass, "android.webkit.WebChromeClient"); //Not the target of this detector if (!isWebChromeClient) { ret...
143
265
408
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/android/WebViewJavascriptEnabledDetector.java
WebViewJavascriptEnabledDetector
sawOpcode
class WebViewJavascriptEnabledDetector extends OpcodeStackDetector { private static final String ANDROID_WEB_VIEW_JAVASCRIPT_TYPE = "ANDROID_WEB_VIEW_JAVASCRIPT"; private BugReporter bugReporter; public WebViewJavascriptEnabledDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; ...
//printOpCode(seen); if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("android/webkit/WebSettings") && getNameConstantOperand().equals("setJavaScriptEnabled")) { OpcodeStack.Item item = stack.getStackItem(0); //First item on the stack is the last ...
138
185
323
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/android/WebViewJavascriptInterfaceDetector.java
WebViewJavascriptInterfaceDetector
sawOpcode
class WebViewJavascriptInterfaceDetector extends OpcodeStackDetector { private static final String ANDROID_WEB_VIEW_INTERFACE_TYPE = "ANDROID_WEB_VIEW_JAVASCRIPT_INTERFACE"; private BugReporter bugReporter; public WebViewJavascriptInterfaceDetector(BugReporter bugReporter) { this.bugReporter = bug...
if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("android/webkit/WebView") && getNameConstantOperand().equals("addJavascriptInterface")) { bugReporter.reportBug(new BugInstance(this, ANDROID_WEB_VIEW_INTERFACE_TYPE, Priorities.NORMAL_PRIORITY) // ...
140
123
263
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/android/WorldWritableDetector.java
WorldWritableDetector
sawOpcode
class WorldWritableDetector extends OpcodeStackDetector { private static final String ANDROID_WORLD_WRITABLE_TYPE = "ANDROID_WORLD_WRITABLE"; private BugReporter bugReporter; public WorldWritableDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public voi...
//printOpCode(seen); if (seen == Const.INVOKEVIRTUAL && getNameConstantOperand().equals("openFileOutput")) { OpcodeStack.Item item = stack.getStackItem(0); //First item on the stack is the last if(StackUtils.isConstantInteger(item)) { if((Integer) item.getConsta...
126
170
296
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/common/ByteCode.java
ByteCode
getPushNumber
class ByteCode { // public static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg) { // System.out.print("[" + String.format("%02d", insHandle.getPosition()) + "] "); // printOpCode(insHandle.getInstruction(),cpg); // } /** * Print the the detail of the given instructio...
Instruction prevIns = h.getInstruction(); if (prevIns instanceof BIPUSH) { BIPUSH ldcCipher = (BIPUSH) prevIns; return ldcCipher.getValue(); } else if (prevIns instanceof SIPUSH) { SIPUSH ldcCipher = (SIPUSH) prevIns; return ldcCipher.getValue(); ...
1,650
112
1,762
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/common/InterfaceUtils.java
InterfaceUtils
isSubtype
class InterfaceUtils { /** * Test if the given class is a subtype of ONE of the super classes given. * <br/> * The following test that the class is a subclass of Hashtable. * * <pre> * boolean isHashtable = InterfaceUtils.isSubtype( classThatCouldBeAHashTable, "java.util.Hashtable"); ...
for(String potentialSuperClass : superClasses) { try { if(Hierarchy.isSubtype(className, potentialSuperClass)) { return true; } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } ...
340
80
420
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/common/JspUtils.java
JspUtils
getContanstBooleanAsString
class JspUtils { /** * * @param precedingInstructions Instructions preceding the call. * @param cpg Constant Pool Gen (need to get constant value such as strings and class names) * @return The string value found or null */ public static String getContanstBooleanAsString(LinkedList<Ins...
//Heuristic to find static Iterator<Instruction> it = precedingInstructions.descendingIterator(); // Weblogic 12 // [0076] ldc_w "true" // [0079] invokestatic weblogic/utils/StringUtils.valueOf (Ljava/lang/Object;)Ljava/lang/String; // [0082] invokestatic java/lang/Boolean.valueOf...
110
827
937
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/common/StackUtils.java
StackUtils
getLocalVariable
class StackUtils { public static boolean isConstantString(OpcodeStack.Item item) { return item.getConstant() != null && item.getConstant() instanceof String; } /** * @param item Stack item (parameter passed to the current function) * @return If the given string reference is not a constan...
for(LocalVariableGen local : methodGen.getLocalVariables()) { if(local.getIndex() == index) { return local; } } return null;
190
50
240
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/common/TaintUtil.java
TaintUtil
isConstantValueAndNotEmpty
class TaintUtil { public static boolean isConstantValueAndNotEmpty(Taint value) {<FILL_FUNCTION_BODY>} public static boolean isConstantValue(Taint value) { return value.getConstantValue() != null || value.getPotentialValue() != null; } }
return (value.getConstantValue() != null && !value.getConstantValue().isEmpty()) || (value.getPotentialValue() != null && !value.getPotentialValue().isEmpty());
81
53
134
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/common/matcher/InvokeMatcherBuilder.java
InvokeMatcherBuilder
matches
class InvokeMatcherBuilder { private List<String> classesNames = new ArrayList<String>(); private List<String> methodNames = new ArrayList<String>(); private List<String> argSignatures = new ArrayList<String>(); public InvokeMatcherBuilder atClass(String... classesNames) { for(String clz : cl...
if(instruction != null && instruction instanceof InvokeInstruction) { InvokeInstruction invokeInstruction = (InvokeInstruction) instruction; if (classesNames.size() != 0 && !classesNames.contains(invokeInstruction.getClassName(cpg))) { return false; } ...
409
172
581
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/cookie/CookieFlagsDetector.java
CookieFlagsDetector
analyzeMethod
class CookieFlagsDetector implements Detector { private static final String INSECURE_COOKIE_TYPE = "INSECURE_COOKIE"; private static final String HTTPONLY_COOKIE_TYPE = "HTTPONLY_COOKIE"; private BugReporter bugReporter; private static final int TRUE_INT_VALUE = 1; public CookieFlagsDetector(Bug...
//System.out.println("==="+m.getName()+"==="); ConstantPoolGen cpg = classContext.getConstantPoolGen(); CFG cfg = classContext.getCFG(m); for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) { Location loc = i.next(); //ByteCode.printOpCode(loc.ge...
977
576
1,553
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/cookie/CookieReadDetector.java
CookieReadDetector
sawOpcode
class CookieReadDetector extends OpcodeStackDetector { private static final String COOKIE_USAGE_TYPE = "COOKIE_USAGE"; private BugReporter bugReporter; public CookieReadDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int seen) {<F...
if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("javax/servlet/http/Cookie") && (getNameConstantOperand().equals("getName") || getNameConstantOperand().equals("getValue") || getNameConstantOperand().equals("getPath"))) { bugReporter.reportBug(ne...
115
139
254
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/cookie/PersistentCookieDetector.java
PersistentCookieDetector
sawOpcode
class PersistentCookieDetector extends OpcodeStackDetector { private BugReporter bugReporter; public PersistentCookieDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int seen) {<FILL_FUNCTION_BODY>} }
if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("javax/servlet/http/Cookie") && getNameConstantOperand().equals("setMaxAge")) { Object maxAge = stack.getStackItem(0).getConstant(); Integer n = (maxAge instanceof Integer) ? (Integer)maxAge : 0; ...
93
191
284
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/cookie/UrlRewritingDetector.java
UrlRewritingDetector
sawOpcode
class UrlRewritingDetector extends OpcodeStackDetector { private static final String URL_REWRITING = "URL_REWRITING"; private final BugReporter bugReporter; public UrlRewritingDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(in...
if (seen == Const.INVOKEINTERFACE && getClassConstantOperand().equals("javax/servlet/http/HttpServletResponse") && (getNameConstantOperand().equals("encodeURL") || getNameConstantOperand().equals("encodeUrl") || getNameConstantOperand().equals("encodeRedirectURL") || getNameCon...
119
155
274
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/BadHexadecimalConversionDetector.java
BadHexadecimalConversionDetector
visitClassContext
class BadHexadecimalConversionDetector implements Detector { private static final String BAD_HEXA_CONVERSION_TYPE = "BAD_HEXA_CONVERSION"; private BugReporter bugReporter; public BadHexadecimalConversionDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override pu...
JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); for (Method m : methodList) { MethodGen methodGen = classContext.getMethodGen(m); //To suspect that an invalid String representation is being build, //we ident...
145
521
666
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/CipherWithNoIntegrityDetector.java
CipherWithNoIntegrityDetector
sawOpcode
class CipherWithNoIntegrityDetector extends OpcodeStackDetector { private static final String ECB_MODE_TYPE = "ECB_MODE"; private static final String PADDING_ORACLE_TYPE = "PADDING_ORACLE"; private static final String CIPHER_INTEGRITY_TYPE = "CIPHER_INTEGRITY"; private static final Pattern AUTHENTICAT...
if ((seen != Const.INVOKESTATIC || !getClassConstantOperand().equals("javax/crypto/Cipher")) || !getNameConstantOperand().equals("getInstance")) { return; } OpcodeStack.Item item = stack.getStackItem(getSigConstantOperand().contains(";L") ? 1 : 0); ...
327
337
664
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/CustomMessageDigestDetector.java
CustomMessageDigestDetector
visitClassContext
class CustomMessageDigestDetector implements Detector { private static final String CUSTOM_MESSAGE_DIGEST_TYPE = "CUSTOM_MESSAGE_DIGEST"; private BugReporter bugReporter; public CustomMessageDigestDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public...
JavaClass javaClass = classContext.getJavaClass(); if ("java.security.MessageDigest".equals(javaClass.getSuperclassName())) { bugReporter.reportBug(new BugInstance(this, CUSTOM_MESSAGE_DIGEST_TYPE, Priorities.NORMAL_PRIORITY) // .addClass(javaClass)); }
142
95
237
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/ErrorMessageExposureDetector.java
ErrorMessageExposureDetector
isVulnerableClassToPrint
class ErrorMessageExposureDetector extends OpcodeStackDetector { private static final String INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE_TYPE = "INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE"; private BugReporter bugReporter; public ErrorMessageExposureDetector(BugReporter bugReporter) { this.bu...
switch(classConstantOperand) { // By following the parent classes of vulnerable class to print case "java/lang/Throwable": case "java/lang/Exception": case "java/lang/Error": // By following the recommendation from the CERT Oracle Secure Coding S...
493
224
717
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/EsapiEncryptorDetector.java
EsapiEncryptorDetector
sawOpcode
class EsapiEncryptorDetector extends OpcodeStackDetector { private static final boolean DEBUG = false; private static final String ESAPI_ENCRYPTOR_TYPE = "ESAPI_ENCRYPTOR"; private BugReporter bugReporter; public EsapiEncryptorDetector(BugReporter bugReporter) { this.bugReporter = bugReporter...
//printOpCode(seen); if (seen == Const.INVOKEINTERFACE && getClassConstantOperand().equals("org/owasp/esapi/Encryptor") && (getNameConstantOperand().equals("encrypt") || getNameConstantOperand().equals("decrypt"))) { bugReporter.reportBug(new BugInstance(this, ESAPI_ENCRYPT...
133
138
271
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/HazelcastSymmetricEncryptionDetector.java
HazelcastSymmetricEncryptionDetector
sawOpcode
class HazelcastSymmetricEncryptionDetector extends OpcodeStackDetector { private static final String HAZELCAST_SYMMETRIC_ENCRYPTION_TYPE = "HAZELCAST_SYMMETRIC_ENCRYPTION"; private BugReporter bugReporter; public HazelcastSymmetricEncryptionDetector(BugReporter bugReporter) { this.bugReporter = bu...
//printOpCode( seen ); if (seen == Const.INVOKESPECIAL && getClassConstantOperand().equals("com/hazelcast/config/SymmetricEncryptionConfig") && getNameConstantOperand().equals("<init>")) { bugReporter.reportBug(new BugInstance(this, HAZELCAST_SYMMETRIC_ENCRYPTION_TYPE, Prio...
145
140
285
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/InsecureSmtpSslDetector.java
InsecureSmtpSslDetector
analyzeMethod
class InsecureSmtpSslDetector implements Detector { private static final String INSECURE_SMTP_SSL = "INSECURE_SMTP_SSL"; private static final List<String> INSECURE_APIS = Arrays.asList( "org.apache.commons.mail.Email", // "org.apache.commons.mail.HtmlEmail", // "org.apache.c...
HashMap<Location, String> sslConnMap = new HashMap<Location, String>(); HashSet<String> sslCertVerSet = new HashSet<String>(); String hostName = null; ConstantPoolGen cpg = classContext.getConstantPoolGen(); CFG cfg = classContext.getCFG(m); for (Iterator<Location> i ...
328
665
993
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/InsufficientKeySizeBlowfishDetector.java
InsufficientKeySizeBlowfishDetector
analyzeMethod
class InsufficientKeySizeBlowfishDetector implements Detector { private static final String BLOWFISH_KEY_SIZE_TYPE = "BLOWFISH_KEY_SIZE"; private BugReporter bugReporter; public InsufficientKeySizeBlowfishDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override ...
//Conditions that needs to fill to identify the vulnerability boolean createBlowfishKeyGen = false; boolean initializeWeakKeyLength = false; Location locationWeakness = null; ConstantPoolGen cpg = classContext.getConstantPoolGen(); CFG cfg = classContext.getCFG(m); ...
255
700
955
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/InsufficientKeySizeRsaDetector.java
InsufficientKeySizeRsaDetector
analyzeMethod
class InsufficientKeySizeRsaDetector implements Detector { private static final String RSA_KEY_SIZE_TYPE = "RSA_KEY_SIZE"; private BugReporter bugReporter; public InsufficientKeySizeRsaDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void visitCl...
//Conditions that needs to fill to identify the vulnerability boolean createRsaKeyGen = false; ConstantPoolGen cpg = classContext.getConstantPoolGen(); CFG cfg = classContext.getCFG(m); for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) { Location ...
391
963
1,354
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/NullCipherDetector.java
NullCipherDetector
sawOpcode
class NullCipherDetector extends OpcodeStackDetector { private static final String NULL_CIPHER_TYPE = "NULL_CIPHER"; private BugReporter bugReporter; public NullCipherDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int seen) {<FIL...
//printOpCode( seen ); if (seen == Const.INVOKESPECIAL && getClassConstantOperand().equals("javax/crypto/NullCipher") && getNameConstantOperand().equals("<init>")) { bugReporter.reportBug(new BugInstance(this, NULL_CIPHER_TYPE, Priorities.NORMAL_PRIORITY) // ...
113
122
235
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/StaticIvDetector.java
StaticIvDetector
analyzeMethod
class StaticIvDetector implements Detector { private static final boolean DEBUG = false; private static final String STATIC_IV = "STATIC_IV"; private final BugReporter bugReporter; public StaticIvDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override publi...
ConstantPoolGen cpg = classContext.getConstantPoolGen(); CFG cfg = classContext.getCFG(m); boolean foundSafeIvGeneration = false; //Detect if the method is doing decryption/unwrapping only. If it is the case, IV should not be generated from this point //therefore it is a false ...
323
1,021
1,344
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/UnencryptedServerSocketDetector.java
UnencryptedServerSocketDetector
sawOpcode
class UnencryptedServerSocketDetector extends OpcodeStackDetector { private static final boolean DEBUG = false; private static final String UNENCRYPTED_SERVER_SOCKET_TYPE = "UNENCRYPTED_SERVER_SOCKET"; private BugReporter bugReporter; public UnencryptedServerSocketDetector(BugReporter bugReporter) { ...
//printOpCode(seen); if (seen == Const.INVOKESPECIAL && getClassConstantOperand().equals("java/net/ServerSocket") && getNameConstantOperand().equals("<init>")) { bugReporter.reportBug(new BugInstance(this, UNENCRYPTED_SERVER_SOCKET_TYPE, Priorities.NORMAL_PRIORITY) // ...
140
126
266
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/UnencryptedSocketDetector.java
UnencryptedSocketDetector
sawOpcode
class UnencryptedSocketDetector extends OpcodeStackDetector { private static final boolean DEBUG = false; private static final String UNENCRYPTED_SOCKET_TYPE = "UNENCRYPTED_SOCKET"; private BugReporter bugReporter; public UnencryptedSocketDetector(BugReporter bugReporter) { this.bugReporter = ...
//printOpCode(seen); if (seen == Const.INVOKESPECIAL && getClassConstantOperand().equals("java/net/Socket") && getNameConstantOperand().equals("<init>")) { int depth = stack.getStackDepth(); String host = "remote host"; //Bonus information for the message ...
134
401
535
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/WeakMessageDigestDetector.java
WeakMessageDigestDetector
sawOpcode
class WeakMessageDigestDetector extends OpcodeStackDetector { private static final String WEAK_MESSAGE_DIGEST_MD5_TYPE = "WEAK_MESSAGE_DIGEST_MD5"; private static final String WEAK_MESSAGE_DIGEST_SHA1_TYPE = "WEAK_MESSAGE_DIGEST_SHA1"; private final BugReporter bugReporter; public WeakMessageDigestDe...
if (seen != Const.INVOKESTATIC) { return; } String className = getClassConstantOperand(); String methodName = getNameConstantOperand(); if (className.equals("java/security/MessageDigest") && methodName.equals("getInstance")) { final OpcodeStack.Item item;...
438
833
1,271
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/WeakTLSDetector.java
WeakTLSDetector
sawOpcode
class WeakTLSDetector extends OpcodeStackDetector { private static final String DEFAULT_HTTP_CLIENT = "DEFAULT_HTTP_CLIENT"; private static final String SSL_CONTEXT = "SSL_CONTEXT"; private BugReporter bugReporter; public WeakTLSDetector(BugReporter bugReporter) { this.bugReporter = bugReport...
if (seen == Const.INVOKESPECIAL && getClassConstantOperand().equals("org/apache/http/impl/client/DefaultHttpClient") && getNameConstantOperand().equals("<init>") && getSigConstantOperand().equals("()V")) { //DefaultHttpClient constructor with no par...
132
387
519
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/WeakTrustManagerDetector.java
WeakTrustManagerDetector
visitClassContext
class WeakTrustManagerDetector implements Detector { private static final boolean DEBUG = false; private static final String WEAK_TRUST_MANAGER_TYPE = "WEAK_TRUST_MANAGER"; private static final String WEAK_HOSTNAME_VERIFIER_TYPE = "WEAK_HOSTNAME_VERIFIER"; private BugReporter bugReporter; public W...
JavaClass javaClass = classContext.getJavaClass(); //The class extends X509TrustManager boolean isTrustManager = InterfaceUtils.isSubtype(javaClass, "javax.net.ssl.X509TrustManager"); boolean isHostnameVerifier = InterfaceUtils.isSubtype(javaClass, "javax.net.ssl.HostnameVerifier"); ...
391
418
809
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/cipher/CipherDetector.java
CipherDetector
getInjectionPoint
class CipherDetector extends BasicInjectionDetector { private static final String DES_USAGE_TYPE = "DES_USAGE"; private static final InvokeMatcherBuilder CIPHER_GET_INSTANCE = invokeInstruction() .atClass("javax/crypto/Cipher") .atMethod("getInstance") .withArgs("(Ljava/la...
assert invoke != null && cpg != null; //ByteCode.printOpCode(invoke,cpg); if(CIPHER_GET_INSTANCE.matches(invoke,cpg)) { return new InjectionPoint(new int[]{0}, getBugPattern()); } else if(CIPHER_GET_INSTANCE_PROVIDER.matches(invoke,cpg)) { return new In...
657
229
886
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/cipher/DesUsageDetector.java
DesUsageDetector
getCipherPriority
class DesUsageDetector extends CipherDetector { public DesUsageDetector(BugReporter bugReporter) { super(bugReporter); } @Override int getCipherPriority(String cipherValue) {<FILL_FUNCTION_BODY>} @Override String getBugPattern() { return "DES_USAGE"; } }
cipherValue = cipherValue.toLowerCase(); if (cipherValue.equals("des") || cipherValue.startsWith("des/")) { return Priorities.NORMAL_PRIORITY; } return Priorities.IGNORE_PRIORITY;
102
75
177
<methods>public void <init>(BugReporter) <variables>private static final com.h3xstream.findsecbugs.common.matcher.InvokeMatcherBuilder CIPHER_GET_INSTANCE,private static final com.h3xstream.findsecbugs.common.matcher.InvokeMatcherBuilder CIPHER_GET_INSTANCE_PROVIDER,private static final java.lang.String DES_USAGE_TYPE,...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/cipher/RsaNoPaddingDetector.java
RsaNoPaddingDetector
getCipherPriority
class RsaNoPaddingDetector extends CipherDetector { public RsaNoPaddingDetector(BugReporter bugReporter) { super(bugReporter); } @Override int getCipherPriority(String cipherValue) {<FILL_FUNCTION_BODY>} @Override String getBugPattern() { return "RSA_NO_PADDING"; } }
//cipherValue = cipherValue.toLowerCase(); if (cipherValue.startsWith("RSA/") && cipherValue.endsWith("/NoPadding")) { return Priorities.NORMAL_PRIORITY; } return Priorities.IGNORE_PRIORITY;
110
81
191
<methods>public void <init>(BugReporter) <variables>private static final com.h3xstream.findsecbugs.common.matcher.InvokeMatcherBuilder CIPHER_GET_INSTANCE,private static final com.h3xstream.findsecbugs.common.matcher.InvokeMatcherBuilder CIPHER_GET_INSTANCE_PROVIDER,private static final java.lang.String DES_USAGE_TYPE,...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/crypto/cipher/TDesUsageDetector.java
TDesUsageDetector
getCipherPriority
class TDesUsageDetector extends CipherDetector { public TDesUsageDetector(BugReporter bugReporter) { super(bugReporter); } @Override int getCipherPriority(String cipherValue) {<FILL_FUNCTION_BODY>} @Override String getBugPattern() { return "TDES_USAGE"; } }
cipherValue = cipherValue.toLowerCase(); if (cipherValue.equals("desede") || cipherValue.startsWith("desede/")) { return Priorities.LOW_PRIORITY; } return Priorities.IGNORE_PRIORITY;
105
75
180
<methods>public void <init>(BugReporter) <variables>private static final com.h3xstream.findsecbugs.common.matcher.InvokeMatcherBuilder CIPHER_GET_INSTANCE,private static final com.h3xstream.findsecbugs.common.matcher.InvokeMatcherBuilder CIPHER_GET_INSTANCE_PROVIDER,private static final java.lang.String DES_USAGE_TYPE,...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/csrf/SpringCsrfProtectionDisabledDetector.java
SpringCsrfProtectionDisabledDetector
sawOpcode
class SpringCsrfProtectionDisabledDetector extends OpcodeStackDetector { private static final String SPRING_CSRF_PROTECTION_DISABLED_TYPE = "SPRING_CSRF_PROTECTION_DISABLED"; private static final InvokeMatcherBuilder CSRF_CONFIGURER_DISABLE_METHOD = invokeInstruction() // .atClass("org/springframe...
if (seen == Const.INVOKEVIRTUAL && CSRF_CONFIGURER_DISABLE_METHOD.matches(this)) { bugReporter.reportBug(new BugInstance(this, SPRING_CSRF_PROTECTION_DISABLED_TYPE, Priorities.HIGH_PRIORITY) // .addClass(this).addMethod(this).addSourceLine(this)); }
209
107
316
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/csrf/SpringCsrfUnrestrictedRequestMappingDetector.java
SpringCsrfUnrestrictedRequestMappingDetector
isVulnerable
class SpringCsrfUnrestrictedRequestMappingDetector implements Detector { private static final String SPRING_CSRF_UNRESTRICTED_REQUEST_MAPPING_TYPE = "SPRING_CSRF_UNRESTRICTED_REQUEST_MAPPING"; private static final String REQUEST_MAPPING_ANNOTATION_TYPE = "Lorg/springframework/web/bind/annotation/RequestMappin...
// If the method is not annotated with `@RequestMapping`, there is no vulnerability. AnnotationEntry requestMappingAnnotation = findRequestMappingAnnotation(method); if (requestMappingAnnotation == null) { return false; } // If the `@RequestMapping` annotation is u...
932
266
1,198
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/JaxRsEndpointDetector.java
JaxRsEndpointDetector
visitClassContext
class JaxRsEndpointDetector implements Detector { private static final boolean DEBUG = false; private static final String JAXRS_ENDPOINT_TYPE = "JAXRS_ENDPOINT"; private BugReporter bugReporter; public JaxRsEndpointDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @...
JavaClass javaClass = classContext.getJavaClass(); for (Method m : javaClass.getMethods()) { for (AnnotationEntry ae : m.getAnnotationEntries()) { //Every method mark with @javax.ws.rs.Path is mark as an Endpoint if (ae.getAnnotationType().equals("Ljavax/ws...
144
155
299
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/JaxWsEndpointDetector.java
JaxWsEndpointDetector
visitClassContext
class JaxWsEndpointDetector implements Detector { private static final boolean DEBUG = false; private static final String JAXWS_ENDPOINT_TYPE = "JAXWS_ENDPOINT"; private BugReporter bugReporter; public JaxWsEndpointDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } ...
JavaClass javaClass = classContext.getJavaClass(); for (Method m : javaClass.getMethods()) { for (AnnotationEntry ae : m.getAnnotationEntries()) { //Every method mark with @javax.jws.WebMethod is mark as an Endpoint if (ae.getAnnotationType().equals("Ljavax...
145
155
300
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/ServletEndpointDetector.java
ServletEndpointDetector
sawOpcode
class ServletEndpointDetector extends OpcodeStackDetector { private static final String GET_PARAMETER_TYPE = "SERVLET_PARAMETER"; private static final String CONTENT_TYPE = "SERVLET_CONTENT_TYPE"; private static final String SERVER_NAME_TYPE = "SERVLET_SERVER_NAME"; private static final String SESSION...
//All call to ServletRequest if (seen == Const.INVOKEINTERFACE && (getClassConstantOperand().equals("javax/servlet/ServletRequest") || getClassConstantOperand().equals("javax/servlet/http/HttpServletRequest"))) { //ServletRequest if (getNameConstantOperand().e...
282
849
1,131
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/SpringMvcEndpointDetector.java
SpringMvcEndpointDetector
visitClassContext
class SpringMvcEndpointDetector implements Detector { private static final String SPRING_ENDPOINT_TYPE = "SPRING_ENDPOINT"; private static final List<String> REQUEST_MAPPING_ANNOTATION_TYPES = Arrays.asList( "Lorg/springframework/web/bind/annotation/RequestMapping;", // "Lorg/springfra...
JavaClass javaClass = classContext.getJavaClass(); method : for (Method m : javaClass.getMethods()) { for (AnnotationEntry ae : m.getAnnotationEntries()) { if (REQUEST_MAPPING_ANNOTATION_TYPES.contains(ae.getAnnotationType())) { bugReporter.reportBug(ne...
280
143
423
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/Struts1EndpointDetector.java
Struts1EndpointDetector
visitClassContext
class Struts1EndpointDetector implements Detector { public static final String STRUTS1_ENDPOINT_TYPE = "STRUTS1_ENDPOINT"; private BugReporter bugReporter; public Struts1EndpointDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void visitClassCont...
JavaClass javaClass = classContext.getJavaClass(); if ("org.apache.struts.action.Action".equals(javaClass.getSuperclassName())) { bugReporter.reportBug(new BugInstance(this, STRUTS1_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) // .addClass(javaClass)); }
136
93
229
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/Struts2EndpointDetector.java
Struts2EndpointDetector
visitClassContext
class Struts2EndpointDetector implements Detector { private static final String STRUTS2_ENDPOINT_TYPE = "STRUTS2_ENDPOINT"; private BugReporter bugReporter; public Struts2EndpointDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void visitClassCon...
JavaClass javaClass = classContext.getJavaClass(); for (Method m : javaClass.getMethods()) { if ("execute".equals(m.getName()) && "()Ljava/lang/String;".equals(m.getSignature())) { bugReporter.reportBug(new BugInstance(this, STRUTS2_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) /...
136
115
251
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/TapestryEndpointDetector.java
TapestryEndpointDetector
visitClassContext
class TapestryEndpointDetector implements Detector { private static final String TAPESTRY_ENDPOINT_TYPE = "TAPESTRY_ENDPOINT"; private BugReporter bugReporter; public TapestryEndpointDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void visitClas...
JavaClass javaClass = classContext.getJavaClass(); if (!javaClass.getPackageName().contains(".pages")) { return; } //The package contains ".pages" and has some references to tapestry // then it must be an endpoint. //The constants pool contains all referen...
141
259
400
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/endpoint/WicketEndpointDetector.java
WicketEndpointDetector
visitClassContext
class WicketEndpointDetector implements Detector { private static final String WICKET_ENDPOINT_TYPE = "WICKET_ENDPOINT"; private BugReporter bugReporter; public WicketEndpointDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void visitClassContext...
JavaClass javaClass = classContext.getJavaClass(); String superClassName = javaClass.getSuperclassName(); if ("org.apache.wicket.markup.html.WebPage".equals(superClassName)) { bugReporter.reportBug(new BugInstance(this, WICKET_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) // ...
132
111
243
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/file/FileUploadFilenameDetector.java
FileUploadFilenameDetector
sawOpcode
class FileUploadFilenameDetector extends OpcodeStackDetector { private static String FILE_UPLOAD_FILENAME_TYPE = "FILE_UPLOAD_FILENAME"; private BugReporter bugReporter; public FileUploadFilenameDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public voi...
if (seen == Const.INVOKEINTERFACE && (getClassConstantOperand().equals("org/apache/wicket/util/upload/FileItem") || getClassConstantOperand().equals("org/apache/commons/fileupload/FileItem")) && getNameConstantOperand().equals("getName")) { b...
117
143
260
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/file/OverlyPermissiveFilePermissionDetector.java
OverlyPermissiveFilePermissionDetector
analyzeMethod
class OverlyPermissiveFilePermissionDetector implements Detector { private static final boolean DEBUG = false; public static final String OVERLY_PERMISSIVE_FILE_PERMISSION = "OVERLY_PERMISSIVE_FILE_PERMISSION"; private final BugReporter bugReporter; public OverlyPermissiveFilePermissionDetector(BugRep...
ConstantPoolGen cpg = classContext.getConstantPoolGen(); CFG cfg = classContext.getCFG(m); boolean addIntToSet = false; boolean callSetPermissions = false; List<Location> locationFound = new ArrayList<Location>(); for (Iterator<Location> i = cfg.locationIterator(); i.h...
350
805
1,155
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/file/PathTraversalDetector.java
PathTraversalDetector
getPriority
class PathTraversalDetector extends BasicInjectionDetector { private static final String PATH_TRAVERSAL_IN_TYPE = "PATH_TRAVERSAL_IN"; private static final String PATH_TRAVERSAL_OUT_TYPE = "PATH_TRAVERSAL_OUT"; private static final String SCALA_PATH_TRAVERSAL_IN_TYPE = "SCALA_PATH_TRAVERSAL_IN"; publ...
if (!taint.isSafe() && taint.hasTag(Taint.Tag.PATH_TRAVERSAL_SAFE)) { return Priorities.IGNORE_PRIORITY; } else { return super.getPriority(taint); }
369
71
440
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/file/SuspiciousCommandDetector.java
SuspiciousCommandDetector
getInjectionPoint
class SuspiciousCommandDetector extends BasicInjectionDetector { private static final InvokeMatcherBuilder RUNTIME_EXEC = invokeInstruction().atClass("java.lang.Runtime").atMethod("exec").withArgs("(Ljava/lang/String;)Ljava/lang/Process;"); private static final InvokeMatcherBuilder RUNTIME_EXEC_WITH_ENV = inv...
assert invoke != null && cpg != null; if (RUNTIME_EXEC.matches(invoke, cpg)) { return new InjectionPoint(new int[]{0}, OverlyPermissiveFilePermissionDetector.OVERLY_PERMISSIVE_FILE_PERMISSION); } if (RUNTIME_EXEC_WITH_ENV.matches(invoke, cpg)) { return new Injec...
398
154
552
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/groovy/GroovyShellDetector.java
GroovyShellDetector
sawOpcode
class GroovyShellDetector extends OpcodeStackDetector { private static final String GROOVY_SHELL_TYPE = "GROOVY_SHELL"; private BugReporter bugReporter; public GroovyShellDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int seen) {...
//printOpCode(seen); if (seen == Const.INVOKEVIRTUAL && getClassConstantOperand().equals("groovy/lang/GroovyShell")) { if(getNameConstantOperand().equals("evaluate") || getNameConstantOperand().equals("parse")) { bugReporter.reportBug(new BugInstance(this, GROOVY_SHELL_TYPE...
123
267
390
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/AbstractTaintDetector.java
AbstractTaintDetector
getLocationIterator
class AbstractTaintDetector implements Detector { protected final BugReporter bugReporter; protected AbstractTaintDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } /** * Allow any concrete implementation of taint detector to skip the analysis of certain files....
try { return classContext.getCFG(method).locationIterator(); } catch (CFGBuilderException ex) { throw new CheckedAnalysisException("cannot get control flow graph", ex); }
1,005
54
1,059
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/BasicInjectionDetector.java
BasicInjectionDetector
getInjectionPoint
class BasicInjectionDetector extends AbstractInjectionDetector { private final Map<ClassMethodSignature, InjectionPoint> injectionMap = new HashMap<>(); private static final SinksLoader SINKS_LOADER = new SinksLoader(); protected BasicInjectionDetector(BugReporter bugReporter) { super(bugReporter)...
assert invoke != null && cpg != null; ClassMethodSignature classMethodSignature = new ClassMethodSignature( BCELUtil.getSlashedClassName(cpg, invoke), invoke.getMethodName(cpg), invoke.getSignature(cpg)); //1. Verify if the class used has a known sink //This will skip ...
1,479
326
1,805
<methods>public void report() <variables>protected final Map<com.h3xstream.findsecbugs.injection.ClassMethodSignature,Set<com.h3xstream.findsecbugs.injection.InjectionSink>> injectionSinks,private final Map<com.h3xstream.findsecbugs.injection.MethodAndSink,com.h3xstream.findsecbugs.taintanalysis.Taint> sinkTaints
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/ClassMethodSignature.java
ClassMethodSignature
from
class ClassMethodSignature { private String className; private String methodName; private String signature; public ClassMethodSignature(String className, String methodName, String signature) { this.className = className; this.methodName = methodName; this.signature = signature; ...
int periodPos = fullMethodName.indexOf('.'); int parenthesisPos = fullMethodName.indexOf('(', periodPos); String className = fullMethodName.substring(0, periodPos); String methodName = fullMethodName.substring(periodPos + 1, parenthesisPos); String signature = fullMethodName.su...
370
106
476
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/LegacyInjectionDetector.java
LegacyInjectionDetector
getInjectionPoint
class LegacyInjectionDetector extends BasicInjectionDetector { protected LegacyInjectionDetector(BugReporter bugReporter) { super(bugReporter); } @Override protected InjectionPoint getInjectionPoint(InvokeInstruction invoke, ConstantPoolGen cpg, InstructionHandle handle) {<FILL_FUN...
InjectionPoint injectionPoint = null; for (InjectionSource source : getInjectionSource()) { injectionPoint = source.getInjectableParameters(invoke, cpg, handle); if (injectionPoint != InjectionPoint.NONE) { break; } } if (injectionPoin...
110
124
234
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/MethodAndSink.java
MethodAndSink
equals
class MethodAndSink { private final ClassMethodSignature classMethodSignature; private final InjectionSink sink; public MethodAndSink(ClassMethodSignature classMethodSignature, InjectionSink sink) { Objects.requireNonNull(classMethodSignature, "classMethodSignature"); Objects.requireNo...
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MethodAndSink that = (MethodAndSink) o; return Objects.equals(classMethodSignature, that.classMethodSignature) && Objects.equals(sink, that.sink);
214
85
299
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/SinksLoader.java
SinksLoader
loadSink
class SinksLoader { private static final String SINK_CONFIG_PATH = "injection-sinks/"; protected SinksLoader() {} protected void loadConfiguredSinks(String filename, String bugType, InjectionPointReceiver receiver) { assert filename != null && bugType != null && !bugType.isEmpty(); try (...
assert line != null && bugType != null && !bugType.isEmpty(); String[] split = line.split("\\:"); if (split.length != 2) { throw new IllegalArgumentException("There must be exactly one ':' in " + line); } String[] stringArguments = split[1].split(","); int le...
629
279
908
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/command/CommandInjectionDetector.java
CommandInjectionDetector
getPriority
class CommandInjectionDetector extends BasicInjectionDetector { public CommandInjectionDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("command.txt", "COMMAND_INJECTION"); loadConfiguredSinks("command-scala.txt", "SCALA_COMMAND_INJECTION"); } @Overri...
if (!taint.isSafe() && taint.hasTag(Taint.Tag.COMMAND_INJECTION_SAFE)) { return Priorities.IGNORE_PRIORITY; } else { return super.getPriority(taint); }
128
71
199
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/crlf/CrlfLogInjectionDetector.java
CrlfLogInjectionDetector
getPriority
class CrlfLogInjectionDetector extends BasicInjectionDetector { public CrlfLogInjectionDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("crlf-logs.txt", "CRLF_INJECTION_LOGS"); } @Override protected int getPriority(Taint taint) {<FILL_FUNCTION_BODY>} }
if (!taint.isSafe()) { //(Condition extracted for clarity) //Either specifically safe for new line or URL encoded which encoded few other characters boolean newLineSafe = taint.hasTag(Taint.Tag.CR_ENCODED) && taint.hasTag(Taint.Tag.LF_ENCODED); boolean urlSafe = ...
113
220
333
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/custom/CustomInjectionDetector.java
CustomInjectionDetector
getPriority
class CustomInjectionDetector extends BasicInjectionDetector { private static final Logger LOG = Logger.getLogger(CustomInjectionDetector.class.getName()); private static final String SYSTEM_PROPERTY = "findsecbugs.injection.sources"; public CustomInjectionDetector(BugReporter bugReporter) { supe...
if (!taint.isSafe() && taint.hasTag(Taint.Tag.CUSTOM_INJECTION_SAFE)) { return Priorities.IGNORE_PRIORITY; } else { return super.getPriority(taint); }
534
72
606
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/formatter/FormatStringManipulationDetector.java
FormatStringManipulationDetector
getPriority
class FormatStringManipulationDetector extends BasicInjectionDetector { public FormatStringManipulationDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("formatter.txt", "FORMAT_STRING_MANIPULATION"); } @Override protected int getPriority(Taint taint) {<FILL_F...
if (taint.isTainted()) { return Priorities.NORMAL_PRIORITY; } else if (!taint.isSafe()) { return Priorities.LOW_PRIORITY; } else { return Priorities.IGNORE_PRIORITY; }
104
83
187
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/http/HttpParameterPollutionDetector.java
HttpParameterPollutionDetector
getPriority
class HttpParameterPollutionDetector extends BasicInjectionDetector { public HttpParameterPollutionDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("http-parameter-pollution.txt", "HTTP_PARAMETER_POLLUTION"); } @Override protected int getPriority(Taint taint)...
if (!taint.isSafe() && (taint.hasOneTag(Taint.Tag.HTTP_POLLUTION_SAFE, Taint.Tag.URL_ENCODED))) { return Priorities.IGNORE_PRIORITY; } else { return super.getPriority(taint); }
111
84
195
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/ldap/LdapInjectionDetector.java
LdapInjectionDetector
getPriority
class LdapInjectionDetector extends BasicInjectionDetector { public LdapInjectionDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("ldap.txt", "LDAP_INJECTION"); } @Override protected int getPriority(Taint taint) {<FILL_FUNCTION_BODY>} }
if (!taint.isSafe() && taint.hasTag(Taint.Tag.LDAP_INJECTION_SAFE)) { return Priorities.IGNORE_PRIORITY; } else { return super.getPriority(taint); }
104
71
175
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/redirect/RedirectionSource.java
RedirectionSource
getInjectableParameters
class RedirectionSource implements InjectionSource { private static final String UNVALIDATED_REDIRECT_TYPE = "UNVALIDATED_REDIRECT"; @Override public InjectionPoint getInjectableParameters(InvokeInstruction ins, ConstantPoolGen cpg, InstructionHandle insHandle) {<FILL_FUNCTION_BODY>} }
if (ins instanceof INVOKEINTERFACE) { String methodName = ins.getMethodName(cpg); String className = ins.getReferenceType(cpg).toString(); if (className.equals("javax.servlet.http.HttpServletResponse") || className.equals("javax.servlet.http.HttpServletRe...
86
371
457
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/redirect/UnvalidatedRedirectDetector.java
UnvalidatedRedirectDetector
getPriority
class UnvalidatedRedirectDetector extends LegacyInjectionDetector { public UnvalidatedRedirectDetector(BugReporter bugReporter) { super(bugReporter); } @Override public InjectionSource[] getInjectionSource() { return new InjectionSource[]{new RedirectionSource()}; } @Override ...
if (taint.hasTag(Taint.Tag.REDIRECT_SAFE)) { return Priorities.IGNORE_PRIORITY; } else { return super.getPriority(taint); }
117
60
177
<methods>public abstract com.h3xstream.findsecbugs.injection.InjectionSource[] getInjectionSource() <variables>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/script/SpelViewDetector.java
SpelViewDetector
sawOpcode
class SpelViewDetector extends OpcodeStackDetector { private BugReporter bugReporter; public SpelViewDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int seen) {<FILL_FUNCTION_BODY>} }
//printOpCode(seen); if(seen == INVOKESPECIAL) { String methodName = getNameConstantOperand(); String className = getClassConstantOperand(); if (methodName.equals("<init>") && className.toLowerCase().endsWith("spelview")) { //Constructor named SpelView() ...
91
159
250
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/smtp/SmtpHeaderInjectionDetector.java
SmtpHeaderInjectionDetector
getPriority
class SmtpHeaderInjectionDetector extends BasicInjectionDetector { public SmtpHeaderInjectionDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("smtp.txt", "SMTP_HEADER_INJECTION"); } @Override protected int getPriority(Taint taint) {<FILL_FUNCTION_BODY>} }
if (!taint.isSafe()) { //New line are the important characters boolean newLineSafe = taint.hasTag(Taint.Tag.CR_ENCODED) && taint.hasTag(Taint.Tag.LF_ENCODED); boolean urlSafe = (taint.hasTag(Taint.Tag.URL_ENCODED)); if(newLineSafe || urlSafe) { re...
106
203
309
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/sql/AndroidSqlInjectionDetector.java
AndroidSqlInjectionDetector
getPriority
class AndroidSqlInjectionDetector extends BasicInjectionDetector { public static final String[] CONTENT_PROVIDER_TYPES = {"android.content.ContentProvider"}; public AndroidSqlInjectionDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("sql-android.txt", "SQL_INJECTION_...
if (!taint.isSafe() && taint.hasTag(Taint.Tag.SQL_INJECTION_SAFE)) { return Priorities.IGNORE_PRIORITY; } else if (!taint.isSafe() && taint.hasTag(Taint.Tag.APOSTROPHE_ENCODED)) { return Priorities.LOW_PRIORITY; } else { return super.getPriority(taint...
134
121
255
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/sql/SqlInjectionDetector.java
SqlInjectionDetector
getPriority
class SqlInjectionDetector extends BasicInjectionDetector { public SqlInjectionDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("sql-hibernate.txt", "SQL_INJECTION_HIBERNATE"); loadConfiguredSinks("sql-jdo.txt", "SQL_INJECTION_JDO"); loadConfiguredSinks("s...
if (!taint.isSafe() && taint.hasTag(Taint.Tag.SQL_INJECTION_SAFE)) { return Priorities.IGNORE_PRIORITY; } else if (!taint.isSafe() && taint.hasTag(Taint.Tag.APOSTROPHE_ENCODED)) { return Priorities.LOW_PRIORITY; } else { return super.getPriority(taint); ...
381
118
499
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/trust/TrustBoundaryViolationAttributeDetector.java
TrustBoundaryViolationAttributeDetector
getPriority
class TrustBoundaryViolationAttributeDetector extends BasicInjectionDetector { public TrustBoundaryViolationAttributeDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("trust-boundary-violation-attribute.txt", "TRUST_BOUNDARY_VIOLATION"); } /** * All or nothin...
if (taint.isTainted()) { return Priorities.NORMAL_PRIORITY; } else if (!taint.isSafe()) { return Priorities.LOW_PRIORITY; } else { return Priorities.IGNORE_PRIORITY; }
219
84
303
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/trust/TrustBoundaryViolationValueDetector.java
TrustBoundaryViolationValueDetector
getPriority
class TrustBoundaryViolationValueDetector extends BasicInjectionDetector { public TrustBoundaryViolationValueDetector(BugReporter bugReporter) { super(bugReporter); loadConfiguredSinks("trust-boundary-violation-value.txt", "TRUST_BOUNDARY_VIOLATION"); } /**= * All or nothing : * ...
//**Low risk** //It is very common that variable are not sanetize and store in session. //By it self it pose little risk. The thinking is the injection or the critical operation //will be catch. //After all storing value in the session is not so different to storing value in loc...
220
185
405
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/injection/xml/XmlInjectionDetector.java
XmlInjectionDetector
getPriorityFromTaintFrame
class XmlInjectionDetector extends BasicInjectionDetector implements TaintFrameAdditionalVisitor { private static final String XML_INJECTION_TYPE = "POTENTIAL_XML_INJECTION"; private static final String[] STRING_CONCAT_CLASS = new String[] {"java/lang/StringBuilder","java/lang/StringBuffer"}; private stat...
Taint taint0 = taintFrame.getStackValue(0); Taint taint1 = taintFrame.getStackValue(1); /** * If the value argument passed to append is unsafe (not constant)[1] and not sanitize for XML (XSS_SAFE) [2] * and the StringBuilder to which the dynamic value is added is within XML t...
1,008
206
1,214
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/jsp/JspIncludeDetector.java
JspIncludeDetector
sawOpcode
class JspIncludeDetector extends OpcodeStackDetector { private static final String JSP_INCLUDE_TYPE = "JSP_INCLUDE"; private BugReporter bugReporter; public JspIncludeDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int seen) {<FILL...
//printOpCode(seen); //Important sample from \plugin\src\test\webapp\includes\jsp_include_1.jsp //org.apache.jasper.runtime.JspRuntimeLibrary //JspRuntimeLibrary.include(request, response, (String)PageContextImpl.evaluateExpression("${param.secret_param}", String.class, _jspx_page_cont...
118
736
854
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/jsp/JspSpringEvalDetector.java
JspSpringEvalDetector
sawOpcode
class JspSpringEvalDetector extends OpcodeStackDetector { private static final String JSP_SPRING_EVAL = "JSP_SPRING_EVAL"; private BugReporter bugReporter; public JspSpringEvalDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void sawOpcode(int see...
//printOpCode(seen); // JspSpringEvalDetector: [0039] ldc "${expression}" // JspSpringEvalDetector: [0041] ldc java/lang/String // JspSpringEvalDetector: [0043] aload_2 // JspSpringEvalDetector: [0044] aconst_null // JspSpringEvalDetector: [0045] invokestatic org/...
124
428
552
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/jsp/JstlOutDetector.java
JstlOutDetector
analyzeMethod
class JstlOutDetector implements Detector { private static final boolean DEBUG = false; private static final String JSP_JSTL_OUT = "JSP_JSTL_OUT"; private static final InvokeMatcherBuilder OUT_TAG_ESCAPE_XML = invokeInstruction().atClass("org.apache.taglibs.standard.tag.rt.core.OutTag", "org.ap...
//Conditions that needs to fill to identify the vulnerability boolean escapeXmlSetToFalse = false; boolean escapeXmlValueUnknown = false; Location locationWeakness = null; ConstantPoolGen cpg = classContext.getConstantPoolGen(); CFG cfg = classContext.getCFG(m); ...
489
734
1,223
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/jsp/XslTransformJspDetector.java
XslTransformJspDetector
visitClassContext
class XslTransformJspDetector implements Detector { private static final String JSP_XSLT = "JSP_XSLT"; private final BugReporter bugReporter; private static final InvokeMatcherBuilder TRANSFORM_TAG_XSLT = invokeInstruction() .atClass("org.apache.taglibs.standard.tag.rt.xml.TransformTag") //...
JavaClass javaClass = classContext.getJavaClass(); try { if (!Hierarchy.isSubtype(javaClass.getClassName(), "javax.servlet.http.HttpServlet")) { return; } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } ...
1,161
150
1,311
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/kotlin/KotlinHardcodePasswordInMapDetector.java
KotlinHardcodePasswordInMapDetector
getInjectionPoint
class KotlinHardcodePasswordInMapDetector extends AbstractHardcodePasswordInMapDetector { private static final String KOTLIN_HARD_CODE_PASSWORD_IN_MAP_TYPE = "HARD_CODE_PASSWORD"; private static final InvokeMatcherBuilder TUPLEKT_TO = invokeInstruction().atMethod("to") .withArgs("(Ljava/lang/Objec...
assert invoke != null && cpg != null; if (TUPLEKT_TO.matches(invoke, cpg)) { return new InjectionPoint(new int[]{0}, KOTLIN_HARD_CODE_PASSWORD_IN_MAP_TYPE); } return InjectionPoint.NONE;
197
83
280
<methods>public void <init>(BugReporter) <variables>private static List<java.lang.String> PASSWORD_WORDS
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/kotlin/KotlinHardcodedPasswordEqualsDetector.java
KotlinHardcodedPasswordEqualsDetector
getInjectionPoint
class KotlinHardcodedPasswordEqualsDetector extends AbstractHardcodedPasswordEqualsDetector { private static final String HARD_CODE_PASSWORD_TYPE = "HARD_CODE_PASSWORD"; private static final InvokeMatcherBuilder KOTLIN_INTRINSICS_ARE_EQUALS_METHOD = invokeInstruction() // .atClass("kotlin/jvm/inte...
if (KOTLIN_INTRINSICS_ARE_EQUALS_METHOD.matches(invoke, cpg)) { return new InjectionPoint(new int[]{0, 1}, HARD_CODE_PASSWORD_TYPE); } return InjectionPoint.NONE;
212
73
285
<methods>public void visitField(FieldInstruction, MethodGen, com.h3xstream.findsecbugs.taintanalysis.TaintFrame, com.h3xstream.findsecbugs.taintanalysis.Taint, int, ConstantPoolGen) throws java.lang.Exception,public void visitInvoke(InvokeInstruction, MethodGen, com.h3xstream.findsecbugs.taintanalysis.TaintFrame, List<...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/ldap/AnonymousLdapDetector.java
AnonymousLdapDetector
visitClassContext
class AnonymousLdapDetector implements Detector { private static final String LDAP_ANONYMOUS = "LDAP_ANONYMOUS"; private BugReporter bugReporter; public AnonymousLdapDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void visitClassContext(Clas...
JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); for (Method m : methodList) { try { analyzeMethod(m, classContext); } catch (CFGBuilderException e) { } catch (DataflowAnalysisException e) { ...
430
88
518
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/ldap/LdapEntryPoisoningDetector.java
LdapEntryPoisoningDetector
sawOpcode
class LdapEntryPoisoningDetector extends OpcodeStackDetector { private String LDAP_ENTRY_POISONING = "LDAP_ENTRY_POISONING"; private static final InvokeMatcherBuilder PATTERN_SEARCH_CONTROLS_INIT = invokeInstruction() // .atClass("javax/naming/directory/SearchControls") // .atMethod("<...
boolean shouldReportBug = false; if(seen == INVOKESPECIAL) { if(PATTERN_SEARCH_CONTROLS_INIT.matches(this)) { OpcodeStack.Item item = stack.getStackItem(1); Object param = item.getConstant(); shouldReportBug = param instanceof Integer && Int...
273
281
554
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/password/AbstractHardcodePasswordInMapDetector.java
AbstractHardcodePasswordInMapDetector
getPriorityFromTaintFrame
class AbstractHardcodePasswordInMapDetector extends BasicInjectionDetector { private static List<String> PASSWORD_WORDS = new ArrayList<String>(); static { //Passwords in various language //http://www.indifferentlanguages.com/words/password PASSWORD_WORDS.add("password"); PASSW...
Taint valueTaint = fact.getStackValue(0); Taint parameterTaint = fact.getStackValue(1); if (valueTaint.getConstantValue() == null || parameterTaint.getConstantValue() == null) { return Priorities.IGNORE_PRIORITY; } String parameterValue = parameterTaint.getConstant...
388
206
594
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/password/AbstractHardcodedPasswordEqualsDetector.java
AbstractHardcodedPasswordEqualsDetector
visitLoad
class AbstractHardcodedPasswordEqualsDetector extends BasicInjectionDetector implements TaintFrameAdditionalVisitor { private static final boolean DEBUG = false; protected AbstractHardcodedPasswordEqualsDetector(BugReporter bugReporter) { super(bugReporter); registerVisitor(this); } @...
//Extract the name of the variable int index = instruction.getIndex(); LocalVariableGen var = StackUtils.getLocalVariable(methodGen, index); if(var == null) { if(DEBUG) System.out.println("Unable to get field name for index "+ index + " in "+methodGen); return; ...
574
354
928
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/password/GoogleApiKeyDetector.java
GoogleApiKeyDetector
visitClassContext
class GoogleApiKeyDetector implements Detector { private static final String HARD_CODE_PASSWORD_TYPE = "HARD_CODE_PASSWORD"; private BugReporter bugReporter; public GoogleApiKeyDetector(BugReporter bugReporter) { this.bugReporter = bugReporter; } @Override public void visitClassConte...
JavaClass javaClass = classContext.getJavaClass(); boolean keyStringField = false; for (Field f : javaClass.getFields()) { if (f.getName().equals("keyString")) { //The expected field name keyStringField = true; break; } } ...
131
360
491
<no_super_class>
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/password/HardcodePasswordInMapDetector.java
HardcodePasswordInMapDetector
getInjectionPoint
class HardcodePasswordInMapDetector extends AbstractHardcodePasswordInMapDetector { private static final String HARD_CODE_PASSWORD_TYPE = "HARD_CODE_PASSWORD"; private static final InvokeMatcherBuilder MAP_PUT_METHOD = invokeInstruction().atMethod("put") .withArgs("(Ljava/lang/Object;Ljava/lang/Ob...
assert invoke != null && cpg != null; if (MAP_PUT_METHOD.matches(invoke, cpg) || MAP_PUT_IF_ABSENT_METHOD.matches(invoke, cpg) || HASHTABLE_SET_PROPERTY.matches(invoke, cpg)) { return new InjectionPoint(new int[]{0}, HARD_CODE_PASSWORD_TYPE); } ...
299
119
418
<methods>public void <init>(BugReporter) <variables>private static List<java.lang.String> PASSWORD_WORDS
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/password/HardcodedPasswordEqualsDetector.java
HardcodedPasswordEqualsDetector
getInjectionPoint
class HardcodedPasswordEqualsDetector extends AbstractHardcodedPasswordEqualsDetector { private static final String HARD_CODE_PASSWORD_TYPE = "HARD_CODE_PASSWORD"; private static final InvokeMatcherBuilder STRING_EQUALS_METHOD = invokeInstruction() // .atClass("java/lang/String").atMethod("equals"...
if(STRING_EQUALS_METHOD.matches(invoke,cpg)) { return new InjectionPoint(new int[]{0,1}, HARD_CODE_PASSWORD_TYPE); } return InjectionPoint.NONE;
183
63
246
<methods>public void visitField(FieldInstruction, MethodGen, com.h3xstream.findsecbugs.taintanalysis.TaintFrame, com.h3xstream.findsecbugs.taintanalysis.Taint, int, ConstantPoolGen) throws java.lang.Exception,public void visitInvoke(InvokeInstruction, MethodGen, com.h3xstream.findsecbugs.taintanalysis.TaintFrame, List<...
find-sec-bugs_find-sec-bugs
find-sec-bugs/findsecbugs-plugin/src/main/java/com/h3xstream/findsecbugs/password/HashUnsafeEqualsDetector.java
HashUnsafeEqualsDetector
visitLoad
class HashUnsafeEqualsDetector extends BasicInjectionDetector implements TaintFrameAdditionalVisitor { private static final String UNSAFE_HASH_EQUALS_TYPE = "UNSAFE_HASH_EQUALS"; private static final InvokeMatcherBuilder STRING_EQUALS_METHOD = invokeInstruction() // .atClass("java/lang/String").at...
//Extract the name of the variable int index = instruction.getIndex(); LocalVariableGen var = StackUtils.getLocalVariable(methodGen, index); if(var == null) { if(DEBUG) System.out.println("Unable to get field name for index "+ index + " in "+methodGen); return; ...
1,028
364
1,392
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.inject...