code
stringlengths
14
2.05k
label
int64
0
1
programming_language
stringclasses
7 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
98
description
stringlengths
36
379
url
stringlengths
36
48
label_name
stringclasses
2 values
public void shouldHaveTheGenericMessageInOutputOfTemplateWhenCustomErrorMessageIsNotProvided() { String output = view.render(new HashMap<>()); assertThat(output, containsString("$('trans_content').update(\"Sorry, an unexpected error occurred. :( Please check the server logs for more information.\");")); }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
public void setLogid(String logid) { synchronized (this) { if ("-".equals(logid)) { this.logid = ""; } else { this.logid = SolrTools.escapeSpecialCharacters(logid); } } }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
public void setImageToShow(String imageToShow) { synchronized (lock) { this.imageToShow = imageToShow; if (viewManager != null) { viewManager.setDropdownSelected(String.valueOf(imageToShow)); } // Reset LOGID (the LOGID setter is called later by PrettyFaces, so if a value is passed, it will still be set) setLogid(""); logger.trace("imageToShow: {}", this.imageToShow); } }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
protected void copyResponse(InputStream is, OutputStream out, byte[] head, boolean base64) throws IOException { if (base64) { try (BufferedInputStream in = new BufferedInputStream(is, BUFFER_SIZE)) { ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] buffer = new byte[0xFFFF]; os.write(head, 0, head.length); for (int len = is.read(buffer); len != -1; len = is.read(buffer)) { os.write(buffer, 0, len); } out.write(mxBase64.encodeToString(os.toByteArray(), false).getBytes()); } } else { out.write(head); Utils.copy(is, out); } }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public static void copy(InputStream in, OutputStream out, int bufferSize) throws IOException { byte[] b = new byte[bufferSize]; int read; while ((read = in.read(b)) != -1) { out.write(b, 0, read); } }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
private String generateTooltipHtml(CmsListInfoBean infoBean) { StringBuffer result = new StringBuffer(); result.append("<p><b>").append(CmsClientStringUtil.shortenString(infoBean.getTitle(), 70)).append("</b></p>"); if (infoBean.hasAdditionalInfo()) { for (CmsAdditionalInfoBean additionalInfo : infoBean.getAdditionalInfo()) { result.append("<p>").append(additionalInfo.getName()).append(":&nbsp;"); // shorten the value to max 45 characters result.append(CmsClientStringUtil.shortenString(additionalInfo.getValue(), 45)).append("</p>"); } } return result.toString(); }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
public Handler<ServerWebSocket> webSocketHandler() { if (!options.isWebsocketBridge()) { return null; } StompServerHandler stomp; synchronized (this) { stomp = this.handler; } return socket -> { if (!socket.path().equals(options.getWebsocketPath())) { LOGGER.error("Receiving a web socket connection on an invalid path (" + socket.path() + "), the path is " + "configured to " + options.getWebsocketPath() + ". Rejecting connection"); socket.reject(); return; } StompServerConnection connection = new StompServerWebSocketConnectionImpl(socket, this, writingFrameHandler); FrameParser parser = new FrameParser(options); socket.exceptionHandler((exception) -> { LOGGER.error("The STOMP server caught a WebSocket error - closing connection", exception); connection.close(); }); socket.endHandler(v -> connection.close()); parser .errorHandler((exception) -> { connection.write( Frames.createInvalidFrameErrorFrame(exception)); connection.close(); } ) .handler(frame -> stomp.handle(new ServerFrameImpl(frame, connection))); socket.handler(parser); }; }
0
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
public StompServer listen(int port, String host, Handler<AsyncResult<StompServer>> handler) { if (port == -1) { handler.handle(Future.failedFuture("TCP server disabled. The port is set to '-1'.")); return this; } StompServerHandler stomp; synchronized (this) { stomp = this.handler; } Objects.requireNonNull(stomp, "Cannot open STOMP server - no StompServerConnectionHandler attached to the " + "server."); server .connectHandler(socket -> { StompServerConnection connection = new StompServerTCPConnectionImpl(socket, this, writingFrameHandler); FrameParser parser = new FrameParser(options); socket.exceptionHandler((exception) -> { LOGGER.error("The STOMP server caught a TCP socket error - closing connection", exception); connection.close(); }); socket.endHandler(v -> connection.close()); parser .errorHandler((exception) -> { connection.write( Frames.createInvalidFrameErrorFrame(exception)); connection.close(); } ) .handler(frame -> stomp.handle(new ServerFrameImpl(frame, connection))); socket.handler(parser); }) .listen(port, host).onComplete(ar -> { if (ar.failed()) { if (handler != null) { vertx.runOnContext(v -> handler.handle(Future.failedFuture(ar.cause()))); } else { LOGGER.error(ar.cause()); } } else { listening = true; LOGGER.info("STOMP server listening on " + ar.result().actualPort()); if (handler != null) { vertx.runOnContext(v -> handler.handle(Future.succeededFuture(this))); } } }); return this; }
0
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
public void setUp(TestContext context) { vertx = rule.vertx(); AuthenticationProvider provider = PropertyFileAuthentication.create(vertx, "test-auth.properties"); server = StompServer.create(vertx, new StompServerOptions().setSecured(true)) .handler(StompServerHandler.create(vertx).authProvider(provider)); server.listen().onComplete(context.asyncAssertSuccess()); }
0
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
void validate(TestContext context, Buffer buffer) { context.assertTrue(buffer.toString().contains("CONNECTED")); context.assertTrue(buffer.toString().contains("version:1.2")); User user = server.stompHandler().getUserBySession(extractSession(buffer.toString())); context.assertNotNull(user); }
0
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
public List<Map<String, Object>> getAllUserGroup(@PathVariable("userId") String userId) { return groupService.getAllUserGroup(userId); }
0
Java
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
public <A extends Output<E>, E extends Exception> void append(A a, char c) throws E { switch (c) { case '&' -> { a.append(AMP); } case '<' -> { a.append(LT); } case '>' -> { a.append(GT); } case '"' -> { a.append(QUOT); } default -> { a.append(c); } } }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
public <A extends Output<E>, E extends Exception> void append(A a, CharSequence csq, int start, int end) throws E { csq = csq == null ? "null" : csq; for (int i = start; i < end; i++) { char c = csq.charAt(i); switch (c) { case '&' -> { a.append(csq, start, i); start = i + 1; a.append(AMP); } case '<' -> { a.append(csq, start, i); start = i + 1; a.append(LT); } case '>' -> { a.append(csq, start, i); start = i + 1; a.append(GT); } case '"' -> { a.append(csq, start, i); start = i + 1; a.append(QUOT); } } } a.append(csq, start, end); }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
public void testParent() throws Exception { LambdaSectionParent m = new LambdaSectionParent("ignore"); String actual = JStachio.render(m); String expected = """ bingo LambdaSectionParent[stuff=ignore] """; assertEquals(expected, actual); }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
public AFile getAFile(String nameOrPath) throws IOException { final SFile filecurrent; // Log.info("AParentFolderRegular::looking for " + nameOrPath); // Log.info("AParentFolderRegular::dir = " + dir); if (dir == null) { filecurrent = new SFile(nameOrPath); } else { filecurrent = dir.getAbsoluteFile().file(nameOrPath); } // Log.info("AParentFolderRegular::Filecurrent " + filecurrent); if (filecurrent.exists()) { return new AFileRegular(filecurrent.getCanonicalFile()); } return null; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public void drawU(UGraphic ug) { for (String s : tmp) { final Display display = Display.getWithNewlines("<:1f4c4:>" + s); TextBlock result = display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam); result.drawU(ug); ug = ug.apply(UTranslate.dy(result.calculateDimension(ug.getStringBounder()).getHeight())); } }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public void add(String line) { if (line.startsWith("/")) tmp.add(line.substring(1)); }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public UImage toUImage(ColorMapper colorMapper, HColor backcolor, HColor forecolor) { final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); if (backcolor == null) { backcolor = HColors.WHITE; } if (forecolor == null) { forecolor = HColors.BLACK; } final HColorGradient gradient = HColors.gradient(backcolor, forecolor, '\0'); for (int col = 0; col < width; col++) { for (int line = 0; line < height; line++) { final int localColor = color[line][col]; if (localColor == -1) { final double coef = 1.0 * gray[line][col] / (16 - 1); final Color c = gradient.getColor(colorMapper, coef, 255); im.setRGB(col, line, c.getRGB()); } else { im.setRGB(col, line, localColor); } } } return new UImage(new PixelImage(im, AffineTransformType.TYPE_BILINEAR)); }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public void setGray(int x, int y, int level) { if (x < 0 || x >= width) { return; } if (y < 0 || y >= height) { return; } if (level < 0 || level >= 16) { throw new IllegalArgumentException(); } gray[y][x] = level; color[y][x] = -1; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public void setColor(int x, int y, int col) { if (x < 0 || x >= width) { return; } if (y < 0 || y >= height) { return; } gray[y][x] = -1; color[y][x] = col; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
private TValue executeReturnLegacyDefine(LineLocation location, TContext context, TMemory memory, List<TValue> args) throws EaterException, EaterExceptionLocated { if (legacyDefinition == null) { throw new IllegalStateException(); } final TMemory copy = getNewMemory(memory, args, Collections.<String, TValue>emptyMap()); final String tmp = context.applyFunctionsAndVariables(copy, location, legacyDefinition); if (tmp == null) { return TValue.fromString(""); } return TValue.fromString(tmp); // eaterReturn.execute(context, copy); // // System.err.println("s3=" + eaterReturn.getValue2()); // return eaterReturn.getValue2(); }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public void executeProcedureInternal(TContext context, TMemory memory, List<TValue> args, Map<String, TValue> named) throws EaterException, EaterExceptionLocated { if (functionType != TFunctionType.PROCEDURE && functionType != TFunctionType.LEGACY_DEFINELONG) { throw new IllegalStateException(); } final TMemory copy = getNewMemory(memory, args, named); context.executeLines(copy, body, TFunctionType.PROCEDURE, false); }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public TFunctionImpl(String functionName, List<TFunctionArgument> args, boolean unquoted, TFunctionType functionType) { final Set<String> names = new HashSet<>(); for (TFunctionArgument tmp : args) { names.add(tmp.getName()); } this.signature = new TFunctionSignature(functionName, args.size(), names); this.args = args; this.unquoted = unquoted; this.functionType = functionType; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public boolean canCover(int nbArg, Set<String> namedArguments) { for (String n : namedArguments) { if (signature.getNamedArguments().contains(n) == false) { return false; } } if (nbArg > args.size()) { return false; } assert nbArg <= args.size(); int neededArgument = 0; for (TFunctionArgument arg : args) { if (namedArguments.contains(arg.getName())) { continue; } if (arg.getOptionalDefaultValue() == null) { neededArgument++; } } if (nbArg < neededArgument) { return false; } assert nbArg >= neededArgument; return true; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public void addBody(StringLocated s) throws EaterExceptionLocated { body.add(s); if (s.getType() == TLineType.RETURN) { this.containsReturn = true; if (functionType == TFunctionType.PROCEDURE) { throw EaterExceptionLocated .located("A procedure cannot have !return directive. Declare it as a function instead ?", s); // this.functionType = TFunctionType.RETURN; } } }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public void finalizeEnddefinelong() { if (functionType != TFunctionType.LEGACY_DEFINELONG) { throw new UnsupportedOperationException(); } if (body.size() == 1) { this.functionType = TFunctionType.LEGACY_DEFINE; this.legacyDefinition = body.get(0).getString(); } }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> args, Map<String, TValue> named) throws EaterException, EaterExceptionLocated { if (functionType == TFunctionType.LEGACY_DEFINE) { return executeReturnLegacyDefine(location, context, memory, args); } if (functionType != TFunctionType.RETURN_FUNCTION) { throw EaterException.unlocated("Illegal call here. Is there a return directive in your function?"); } final TMemory copy = getNewMemory(memory, args, named); final TValue result = context.executeLines(copy, body, TFunctionType.RETURN_FUNCTION, true); if (result == null) { throw EaterException.unlocated("No return directive found in your function"); } return result; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
private TMemory getNewMemory(TMemory memory, List<TValue> values, Map<String, TValue> namedArguments) { final Map<String, TValue> result = new HashMap<String, TValue>(); int ivalue = 0; for (TFunctionArgument arg : args) { final TValue value; if (namedArguments.containsKey(arg.getName())) { value = namedArguments.get(arg.getName()); } else if (ivalue < values.size()) { value = values.get(ivalue); ivalue++; } else { value = arg.getOptionalDefaultValue(); } if (value == null) { throw new IllegalStateException(); } result.put(arg.getName(), value); } return memory.forkFromGlobal(result); }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public static Collection<SFile> fileCandidates() { final Set<SFile> result = new TreeSet<>(); final String classpath = System.getProperty("java.class.path"); String[] classpathEntries = classpath.split(SFile.pathSeparator); for (String s : classpathEntries) { if (s == null) continue; SFile dir = new SFile(s); if (dir.isFile()) { dir = dir.getParentFile(); } if (dir != null && dir.isDirectory()) { result.add(dir.file("license.txt")); } } return result; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public static BufferedImage retrieveDistributorImage(LicenseInfo licenseInfo) { if (licenseInfo.getLicenseType() != LicenseType.DISTRIBUTOR) { return null; } try { final byte[] s1 = PLSSignature.retrieveDistributorImageSignature(); if (SignatureUtils.toHexString(s1).equals(SignatureUtils.toHexString(licenseInfo.sha)) == false) { return null; } final InputStream dis = PSystemVersion.class.getResourceAsStream("/distributor.png"); if (dis == null) { return null; } try { final BufferedImage result = SImageIO.read(dis); return result; } finally { dis.close(); } } catch (Exception e) { Logme.error(e); } return null; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public static synchronized LicenseInfo retrieveNamedSlow() { cache = LicenseInfo.NONE; if (OptionFlags.ALLOW_INCLUDE == false) { return cache; } final String key = prefs.get("license", ""); if (key.length() > 0) { cache = setIfValid(retrieveNamed(key), cache); if (cache.isValid()) { return cache; } } for (SFile f : fileCandidates()) { try { if (f.exists() && f.canRead()) { final LicenseInfo result = retrieve(f); if (result == null) { return null; } cache = setIfValid(result, cache); if (cache.isValid()) { return cache; } } } catch (IOException e) { Log.info("Error " + e); // Logme.error(e); } } return cache; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
private static LicenseInfo retrieve(SFile f) throws IOException { final BufferedReader br = f.openBufferedReader(); if (br == null) { return null; } try { final String s = br.readLine(); final LicenseInfo result = retrieveNamed(s); if (result != null) { Log.info("Reading license from " + f.getAbsolutePath()); } return result; } finally { br.close(); } }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
public static LicenseInfo retrieveDistributor() { final InputStream dis = PSystemVersion.class.getResourceAsStream("/distributor.txt"); if (dis == null) { return null; } try { final BufferedReader br = new BufferedReader(new InputStreamReader(dis)); final String licenseString = br.readLine(); br.close(); final LicenseInfo result = PLSSignature.retrieveDistributor(licenseString); final Throwable creationPoint = new Throwable(); creationPoint.fillInStackTrace(); for (StackTraceElement ste : creationPoint.getStackTrace()) { if (ste.toString().contains(result.context)) { return result; } } return null; } catch (Exception e) { Logme.error(e); return null; } }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
private static LicenseInfo setIfValid(LicenseInfo value, LicenseInfo def) { if (value.isValid() || def.isNone()) { return value; } return def; }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
static public void setAllowIncludeFalse() { ALLOW_INCLUDE = false; }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
private boolean isAllowed(AFile file) throws IOException { // ::comment when __CORE__ if (OptionFlags.ALLOW_INCLUDE) return true; if (file != null) { final SFile folder = file.getSystemFolder(); // System.err.println("canonicalPath=" + path + " " + folder + " " + // INCLUDE_PATH); if (includePath().contains(folder)) return true; } // ::done return false; }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public AFile getAFile(String nameOrPath) throws IOException { // Log.info("ImportedFiles::getAFile nameOrPath = " + nameOrPath); // Log.info("ImportedFiles::getAFile currentDir = " + currentDir); final AParentFolder dir = currentDir; if (dir == null || isAbsolute(nameOrPath)) { return new AFileRegular(new SFile(nameOrPath).getCanonicalFile()); } // final File filecurrent = SecurityUtils.File(dir.getAbsoluteFile(), // nameOrPath); final AFile filecurrent = dir.getAFile(nameOrPath); Log.info("ImportedFiles::getAFile filecurrent = " + filecurrent); if (filecurrent != null && filecurrent.isOk()) { return filecurrent; } for (SFile d : getPath()) { if (d.isDirectory()) { final SFile file = d.file(nameOrPath); if (file.exists()) { return new AFileRegular(file.getCanonicalFile()); } } else if (d.isFile()) { final AFileZipEntry zipEntry = new AFileZipEntry(d, nameOrPath); if (zipEntry.isOk()) { return zipEntry; } } } return filecurrent; }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public ImportedFiles withCurrentDir(AParentFolder newCurrentDir) { if (newCurrentDir == null) { return this; } return new ImportedFiles(imported, newCurrentDir); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public FileWithSuffix getFile(String filename, String suffix) throws IOException { final int idx = filename.indexOf('~'); final AFile file; final String entry; if (idx == -1) { file = getAFile(filename); entry = null; } else { file = getAFile(filename.substring(0, idx)); entry = filename.substring(idx + 1); } if (isAllowed(file) == false) return FileWithSuffix.none(); return new FileWithSuffix(filename, suffix, file, entry); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
private boolean isFileOk() { // ::comment when __CORE__ if (SecurityUtils.getSecurityProfile() == SecurityProfile.SANDBOX) // In SANDBOX, we cannot read any files return false; // In any case SFile should not access the security folders // (the files must be handled internally) try { if (isDenied()) return false; } catch (IOException e) { return false; } // Files in "plantuml.include.path" and "plantuml.allowlist.path" are ok. if (isInAllowList(SecurityUtils.getPath(SecurityUtils.PATHS_INCLUDES))) return true; if (isInAllowList(SecurityUtils.getPath(SecurityUtils.ALLOWLIST_LOCAL_PATHS))) return true; if (SecurityUtils.getSecurityProfile() == SecurityProfile.INTERNET) return false; if (SecurityUtils.getSecurityProfile() == SecurityProfile.ALLOWLIST) return false; if (SecurityUtils.getSecurityProfile() != SecurityProfile.UNSECURE) { // For UNSECURE, we did not do those checks final String path = getCleanPathSecure(); if (path.startsWith("/etc/") || path.startsWith("/dev/") || path.startsWith("/boot/") || path.startsWith("/proc/") || path.startsWith("/sys/")) return false; if (path.startsWith("//")) return false; } // ::done return true; }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public static SFile fromFile(File internal) { if (internal == null) { return null; } return new SFile(internal); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
private boolean isUrlOk() { // ::comment when __CORE__ if (SecurityUtils.getSecurityProfile() == SecurityProfile.SANDBOX) // In SANDBOX, we cannot read any URL return false; if (SecurityUtils.getSecurityProfile() == SecurityProfile.LEGACY) return true; if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) // We are UNSECURE anyway return true; if (isInUrlAllowList()) // ::done return true; // ::comment when __CORE__ if (SecurityUtils.getSecurityProfile() == SecurityProfile.INTERNET) { if (forbiddenURL(cleanPath(internal.toString()))) return false; final int port = internal.getPort(); // Using INTERNET profile, port 80 and 443 are ok return port == 80 || port == 443 || port == -1; } return false; // ::done }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public static boolean isSecurityEnv(String name) { return name != null && name.toLowerCase().startsWith("plantuml.security."); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
private boolean fileExists(String path) { final SFile f = new SFile(path); return f.exists(); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values, Map<String, TValue> named) throws EaterException, EaterExceptionLocated { // ::comment when __CORE__ if (OptionFlags.ALLOW_INCLUDE == false) // ::done return TValue.fromBoolean(false); // ::comment when __CORE__ final String path = values.get(0).toString(); return TValue.fromBoolean(fileExists(path)); // ::done }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
private String getenv(String name) { // Check, if the script requests secret information. // A plantuml server should have an own SecurityManager to // avoid access to properties and environment variables, but we should // also stop here in other deployments. if (SecurityUtils.isSecurityEnv(name)) return null; final String env = System.getProperty(name); if (env != null) return env; return System.getenv(name); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values, Map<String, TValue> named) throws EaterException, EaterExceptionLocated { // ::comment when __CORE__ if (OptionFlags.ALLOW_INCLUDE == false) // ::done return TValue.fromString(""); // ::comment when __CORE__ final String name = values.get(0).toString(); final String value = getenv(name); if (value == null) return TValue.fromString(""); return TValue.fromString(value); // ::done }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
private String loadStringData(String path, String charset) throws EaterException, UnsupportedEncodingException { byte[] byteData = null; if (path.startsWith("http://") || path.startsWith("https://")) { final SURL url = SURL.create(path); if (url == null) throw EaterException.located("load JSON: Invalid URL " + path); byteData = url.getBytes(); // ::comment when __CORE__ } else { try { final SFile file = FileSystem.getInstance().getFile(path); if (file != null && file.exists() && file.canRead() && !file.isDirectory()) { final ByteArrayOutputStream out = new ByteArrayOutputStream(1024 * 8); FileUtils.copyToStream(file, out); byteData = out.toByteArray(); } } catch (IOException e) { Logme.error(e); throw EaterException.located("load JSON: Cannot read file " + path + ". " + e.getMessage()); } // ::done } if (byteData == null || byteData.length == 0) return null; // no length, no data (we want the default) return new String(byteData, charset); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public static synchronized LicenseInfo retrieveNamedSlow() { cache = LicenseInfo.NONE; if (OptionFlags.ALLOW_INCLUDE == false) return cache; final String key = prefs.get("license", ""); if (key.length() > 0) { cache = setIfValid(retrieveNamed(key), cache); if (cache.isValid()) return cache; } for (SFile f : fileCandidates()) { try { if (f.exists() && f.canRead()) { final LicenseInfo result = retrieve(f); if (result == null) return null; cache = setIfValid(result, cache); if (cache.isValid()) return cache; } } catch (IOException e) { Log.info("Error " + e); // Logme.error(e); } } return cache; }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public static PSystemVersion createShowVersion2(UmlSource source) { final List<String> strings = new ArrayList<>(); strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")"); strings.add("(" + License.getCurrent() + " source distribution)"); // :: uncomment when __CORE__ // strings.add(" "); // strings.add("Compiled with CheerpJ 2.3"); // strings.add("Powered by CheerpJ, a Leaning Technologies Java tool"); // :: done // :: comment when __CORE__ GraphvizCrash.checkOldVersionWarning(strings); if (OptionFlags.ALLOW_INCLUDE) { if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) strings.add("Loaded from " + Version.getJarPath()); if (OptionFlags.getInstance().isWord()) { strings.add("Word Mode"); strings.add("Command Line: " + Run.getCommandLine()); strings.add("Current Dir: " + new SFile(".").getAbsolutePath()); strings.add("plantuml.include.path: " + PreprocessorUtils.getenv(SecurityUtils.PATHS_INCLUDES)); } } strings.add(" "); GraphvizUtils.addDotStatus(strings, true); strings.add(" "); for (String name : OptionPrint.interestingProperties()) strings.add(name); for (String v : OptionPrint.interestingValues()) strings.add(v); // ::done return new PSystemVersion(source, true, strings); }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public static byte[] compress(int[] input) throws IOException { return rawCompress(input, input.length * 4); // int uses 4 bytes }
0
Java
CWE-190
Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
public static byte[] compress(double[] input) throws IOException { return rawCompress(input, input.length * 8); // double uses 8 bytes }
0
Java
CWE-190
Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
public static byte[] compress(float[] input) throws IOException { return rawCompress(input, input.length * 4); // float uses 4 bytes }
0
Java
CWE-190
Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
public static byte[] compress(short[] input) throws IOException { return rawCompress(input, input.length * 2); // short uses 2 bytes }
0
Java
CWE-190
Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
public static byte[] compress(char[] input) throws IOException { return rawCompress(input, input.length * 2); // char uses 2 bytes }
0
Java
CWE-190
Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
public static byte[] compress(long[] input) throws IOException { return rawCompress(input, input.length * 8); // long uses 8 bytes }
0
Java
CWE-190
Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
public AbstractSniHandler() { this(0L); }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public SniHandler(Mapping<? super String, ? extends SslContext> mapping, long handshakeTimeoutMillis) { this(new AsyncMappingAdapter(mapping), handshakeTimeoutMillis); }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping) { this(mapping, 0L); }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping, long handshakeTimeoutMillis) { super(handshakeTimeoutMillis); this.mapping = (AsyncMapping<String, SslContext>) ObjectUtil.checkNotNull(mapping, "mapping"); }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public void testSniHandlerFiresHandshakeTimeout() throws Exception { SniHandler handler = new SniHandler(new Mapping<String, SslContext>() { @Override public SslContext map(String input) { throw new UnsupportedOperationException("Should not be called"); } }, 10); final AtomicReference<SniCompletionEvent> completionEventRef = new AtomicReference<SniCompletionEvent>(); EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof SniCompletionEvent) { completionEventRef.set((SniCompletionEvent) evt); } } }); try { while (completionEventRef.get() == null) { Thread.sleep(100); // We need to run all pending tasks as the handshake timeout is scheduled on the EventLoop. ch.runPendingTasks(); } SniCompletionEvent completionEvent = completionEventRef.get(); assertNotNull(completionEvent); assertNotNull(completionEvent.cause()); assertEquals(SslHandshakeTimeoutException.class, completionEvent.cause().getClass()); } finally { ch.finishAndReleaseAll(); } }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public void testDecorationWithNull() { Http2ConnectionDecoder delegate = mock(Http2ConnectionDecoder.class); Http2EmptyDataFrameConnectionDecoder decoder = new Http2EmptyDataFrameConnectionDecoder(delegate, 2); decoder.frameListener(null); assertNull(decoder.frameListener()); }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public void testDecoration() { Http2ConnectionDecoder delegate = mock(Http2ConnectionDecoder.class); final ArgumentCaptor<Http2FrameListener> listenerArgumentCaptor = ArgumentCaptor.forClass(Http2FrameListener.class); when(delegate.frameListener()).then(new Answer<Http2FrameListener>() { @Override public Http2FrameListener answer(InvocationOnMock invocationOnMock) { return listenerArgumentCaptor.getValue(); } }); Http2FrameListener listener = mock(Http2FrameListener.class); Http2EmptyDataFrameConnectionDecoder decoder = new Http2EmptyDataFrameConnectionDecoder(delegate, 2); decoder.frameListener(listener); verify(delegate).frameListener(listenerArgumentCaptor.capture()); assertThat(decoder.frameListener(), CoreMatchers.not(CoreMatchers.instanceOf(Http2EmptyDataFrameListener.class))); assertThat(decoder.frameListener0(), CoreMatchers.instanceOf(Http2EmptyDataFrameListener.class)); }
0
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
public Bin(String name, Object value) { this.name = name; this.value = Value.get(value); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static Bin asBlob(String name, Object value) { return new Bin(name, Value.getAsBlob(value)); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public int write(byte[] buffer, int offset) { System.arraycopy(bytes, 0, buffer, offset, bytes.length); return bytes.length; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static Value getAsBlob(Object value) { return (value == null)? NullValue.INSTANCE : new BlobValue(value); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public int getType() { return ParticleType.JBLOB; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void pack(Packer packer) { packer.packBlob(object); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static byte[] serialize(Object val) { if (DisableSerializer) { throw new AerospikeException("Object serializer has been disabled"); } try (ByteArrayOutputStream bstream = new ByteArrayOutputStream()) { try (ObjectOutputStream ostream = new ObjectOutputStream(bstream)) { ostream.writeObject(val); } return bstream.toByteArray(); } catch (Throwable e) { throw new AerospikeException.Serialize(e); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void validateKeyType() { throw new AerospikeException(ResultCode.PARAMETER_ERROR, "Invalid key type: jblob"); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public String toString() { return Buffer.bytesToHexString(bytes); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public Object getObject() { return object; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public int hashCode() { return object.hashCode(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public boolean equals(Object other) { return (other != null && this.getClass().equals(other.getClass()) && this.object.equals(((BlobValue)other).object)); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public BlobValue(Object object) { this.object = object; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public int estimateSize() throws AerospikeException.Serialize { bytes = serialize(object); return bytes.length; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static Value get(Object value) { if (value == null) { return NullValue.INSTANCE; } if (value instanceof Value) { return (Value)value; } if (value instanceof byte[]) { return new BytesValue((byte[])value); } if (value instanceof String) { return new StringValue((String)value); } if (value instanceof Integer) { return new IntegerValue((Integer)value); } if (value instanceof Long) { return new LongValue((Long)value); } if (value instanceof List<?>) { return new ListValue((List<?>)value); } if (value instanceof Map<?,?>) { return new MapValue((Map<?,?>)value); } if (value instanceof Double) { return new DoubleValue((Double)value); } if (value instanceof Float) { return new FloatValue((Float)value); } if (value instanceof Short) { return new ShortValue((Short)value); } if (value instanceof Boolean) { if (UseBoolBin) { return new BooleanValue((Boolean)value); } else { return new BoolIntValue((Boolean)value); } } if (value instanceof Byte) { return new ByteValue((byte)value); } if (value instanceof Character) { return Value.get(((Character)value).charValue()); } if (value instanceof Enum) { return new StringValue(value.toString()); } if (value instanceof UUID) { return new StringValue(value.toString()); } if (value instanceof ByteBuffer) { ByteBuffer bb = (ByteBuffer)value; return new BytesValue(bb.array()); } return new BlobValue(value); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public LuaValue getLuaValue(LuaInstance instance) { return LuaString.valueOf(bytes); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static Object bytesToObject(byte[] buf, int offset, int length) { if (length <= 0) { return null; } if (Value.DisableDeserializer) { throw new AerospikeException.Serialize("Object deserializer has been disabled"); } try (ByteArrayInputStream bastream = new ByteArrayInputStream(buf, offset, length)) { try (ObjectInputStream oistream = new ObjectInputStream(bastream)) { return oistream.readObject(); } } catch (Throwable e) { throw new AerospikeException.Serialize(e); } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public static Object bytesToParticle(int type, byte[] buf, int offset, int len) throws AerospikeException { switch (type) { case ParticleType.STRING: return Buffer.utf8ToString(buf, offset, len); case ParticleType.INTEGER: return Buffer.bytesToNumber(buf, offset, len); case ParticleType.BOOL: return Buffer.bytesToBool(buf, offset, len); case ParticleType.DOUBLE: return Buffer.bytesToDouble(buf, offset); case ParticleType.BLOB: return Arrays.copyOfRange(buf, offset, offset+len); case ParticleType.JBLOB: return Buffer.bytesToObject(buf, offset, len); case ParticleType.GEOJSON: return Buffer.bytesToGeoJSON(buf, offset, len); case ParticleType.HLL: return Buffer.bytesToHLL(buf, offset, len); case ParticleType.LIST: return Unpacker.unpackObjectList(buf, offset, len); case ParticleType.MAP: return Unpacker.unpackObjectMap(buf, offset, len); default: return null; } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public LuaValue getLuaValue(int type, byte[] buf, int offset, int len) throws AerospikeException { if (len <= 0) { return LuaValue.NIL; } switch (type) { case ParticleType.STRING: byte[] copy = new byte[len]; System.arraycopy(buf, offset, copy, 0, len); return LuaString.valueOf(copy, 0, len); case ParticleType.INTEGER: if (len <= 4) { return LuaInteger.valueOf(Buffer.bytesToInt(buf, offset)); } if (len <= 8) { return LuaInteger.valueOf(Buffer.bytesToLong(buf, offset)); } throw new AerospikeException("Lua BigInteger not implemented."); case ParticleType.BOOL: return LuaBoolean.valueOf(Buffer.bytesToBool(buf, offset, len)); case ParticleType.DOUBLE: return LuaDouble.valueOf(Buffer.bytesToDouble(buf, offset)); case ParticleType.BLOB: byte[] blob = new byte[len]; System.arraycopy(buf, offset, blob, 0, len); return new LuaBytes(this, blob); case ParticleType.JBLOB: Object object = Buffer.bytesToObject(buf, offset, len); return new LuaJavaBlob(object); case ParticleType.LIST: { LuaUnpacker unpacker = new LuaUnpacker(this, buf, offset, len); return unpacker.unpackList(); } case ParticleType.MAP: { LuaUnpacker unpacker = new LuaUnpacker(this, buf, offset, len); return unpacker.unpackMap(); } case ParticleType.GEOJSON: // skip the flags int ncells = Buffer.bytesToShort(buf, offset + 1); int hdrsz = 1 + 2 + (ncells * 8); return new LuaGeoJSON(new String(buf, offset + hdrsz, len - hdrsz)); default: return LuaValue.NIL; } }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
protected LuaValue getJavaBlob(Object value) { return new LuaJavaBlob(value); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void packBlob(Object val) { byte[] bytes = BlobValue.serialize(val); packByteArrayBegin(bytes.length + 1); packByte(ParticleType.JBLOB); packByteArray(bytes, 0, bytes.length); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void packObject(Object obj) { if (obj == null) { packNil(); return; } if (obj instanceof Value) { Value value = (Value)obj; value.pack(this); return; } if (obj instanceof byte[]) { packParticleBytes((byte[])obj); return; } if (obj instanceof String) { packParticleString((String)obj); return; } if (obj instanceof Integer) { packInt((Integer)obj); return; } if (obj instanceof Long) { packLong((Long)obj); return; } if (obj instanceof List<?>) { packList((List<?>)obj); return; } if (obj instanceof Map<?,?>) { packMap((Map<?,?>)obj); return; } if (obj instanceof Double) { packDouble((Double)obj); return; } if (obj instanceof Float) { packFloat((Float)obj); return; } if (obj instanceof Short) { packInt((Short)obj); return; } if (obj instanceof Boolean) { packBoolean((Boolean)obj); return; } if (obj instanceof Byte) { packInt(((Byte)obj) & 0xff); return; } if (obj instanceof Character) { packInt(((Character)obj).charValue()); return; } if (obj instanceof Enum) { packString(obj.toString()); return; } if (obj instanceof UUID) { packString(obj.toString()); return; } if (obj instanceof ByteBuffer) { packByteBuffer((ByteBuffer) obj); return; } packBlob(obj); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
private T unpackBlob(int count) throws IOException, ClassNotFoundException { int type = buffer[offset++] & 0xff; count--; T val; switch (type) { case ParticleType.STRING: val = getString(Buffer.utf8ToString(buffer, offset, count)); break; case ParticleType.JBLOB: if (Value.DisableDeserializer) { throw new AerospikeException.Serialize("Object deserializer has been disabled"); } try (ByteArrayInputStream bastream = new ByteArrayInputStream(buffer, offset, count)) { try (ObjectInputStream oistream = new ObjectInputStream(bastream)) { val = getJavaBlob(oistream.readObject()); } } catch (Throwable e) { throw new AerospikeException.Serialize(e); } break; case ParticleType.GEOJSON: val = getGeoJSON(Buffer.utf8ToString(buffer, offset, count)); break; default: val = getBlob(Arrays.copyOfRange(buffer, offset, offset + count)); break; } offset += count; return val; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
protected Object getJavaBlob(Object value) { return value; }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void runListRangeExample(AerospikeClient client, Parameters params) { Key key = new Key(params.namespace, params.set, "mapkey"); String binName = "mapbin"; // Delete record if it already exists. client.delete(params.writePolicy, key); List<Value> l1 = new ArrayList<Value>(); l1.add(Value.get(new GregorianCalendar(2018, 1, 1).getTime())); l1.add(Value.get(1)); List<Value> l2 = new ArrayList<Value>(); l2.add(Value.get(new GregorianCalendar(2018, 1, 2).getTime())); l2.add(Value.get(2)); List<Value> l3 = new ArrayList<Value>(); l3.add(Value.get(new GregorianCalendar(2018, 2, 1).getTime())); l3.add(Value.get(3)); List<Value> l4 = new ArrayList<Value>(); l4.add(Value.get(new GregorianCalendar(2018, 2, 2).getTime())); l4.add(Value.get(4)); List<Value> l5 = new ArrayList<Value>(); l5.add(Value.get(new GregorianCalendar(2018, 2, 5).getTime())); l5.add(Value.get(5)); Map<Value,Value> inputMap = new HashMap<Value,Value>(); inputMap.put(Value.get("Charlie"), Value.get(l1)); inputMap.put(Value.get("Jim"), Value.get(l2)); inputMap.put(Value.get("John"), Value.get(l3)); inputMap.put(Value.get("Harry"), Value.get(l4)); inputMap.put(Value.get("Bill"), Value.get(l5)); // Write values to empty map. Record record = client.operate(params.writePolicy, key, MapOperation.putItems(MapPolicy.Default, binName, inputMap) ); console.info("Record: " + record); List<Value> end = new ArrayList<Value>(); end.add(Value.get(new GregorianCalendar(2018, 2, 2).getTime())); end.add(Value.getAsNull()); // Delete values < end. record = client.operate(params.writePolicy, key, MapOperation.removeByValueRange(binName, null, Value.get(end), MapReturnType.COUNT) ); console.info("Record: " + record); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void addNullValue() { Version version = Version.getServerVersion(client, null); // Do not run on servers < 3.6.1 if (version.isLess(3, 6, 1)) { return; } Key key = new Key(args.namespace, args.set, "addkey"); String binName = "addbin"; // Delete record if it already exists. client.delete(null, key); Bin bin = new Bin(binName, (Long)null); AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() { public void run() { client.add(null, key, bin); } }); assertEquals(ae.getResultCode(), ResultCode.PARAMETER_ERROR); }
0
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
public void setKeyParams() throws Exception { assertPlotParam("key", "out"); assertPlotParam("key", "left"); assertPlotParam("key", "top"); assertPlotParam("key", "center"); assertPlotParam("key", "right"); assertPlotParam("key", "horiz"); assertPlotParam("key", "box"); assertPlotParam("key", "bottom"); assertInvalidPlotParam("yrange", "out%20right%20top%0aset%20yrange%20[33:system(%20"); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void setLabelParams() throws Exception { assertPlotParam("ylabel", "This is good"); assertPlotParam("ylabel", " and so Is this - _ yay"); assertInvalidPlotParam("ylabel", "[33:system(%20"); assertInvalidPlotParam("title", "[33:system(%20"); assertInvalidPlotParam("y2label", "[33:system(%20"); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void setSmoothParams() throws Exception { assertPlotParam("smooth", "unique"); assertPlotParam("smooth", "frequency"); assertPlotParam("smooth", "fnormal"); assertPlotParam("smooth", "cumulative"); assertPlotParam("smooth", "cnormal"); assertPlotParam("smooth", "bins"); assertPlotParam("smooth", "csplines"); assertPlotParam("smooth", "acsplines"); assertPlotParam("smooth", "mcsplines"); assertPlotParam("smooth", "bezier"); assertPlotParam("smooth", "sbezier"); assertPlotParam("smooth", "unwrap"); assertPlotParam("smooth", "zsort"); assertInvalidPlotParam("smooth", "[33:system(%20"); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void setFormatParams() throws Exception { assertPlotParam("yformat", "%25.2f"); assertPlotParam("y2format", "%25.2f"); assertPlotParam("xformat", "%25.2f"); assertPlotParam("yformat", "%253.0em"); assertPlotParam("yformat", "%253.0em%25%25"); assertPlotParam("yformat", "%25.2f seconds"); assertPlotParam("yformat", "%25.0f ms"); assertInvalidPlotParam("yformat", "%252.[33:system"); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void setStyleParams() throws Exception { assertPlotParam("style", "linespoint"); assertPlotParam("style", "points"); assertPlotParam("style", "circles"); assertPlotParam("style", "dots"); assertInvalidPlotParam("style", "dots%20[33:system(%20"); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void badRequest(final BadRequestException exception) { logWarn("Bad Request on " + request().getUri() + ": " + exception.getMessage()); if (this.api_version > 0) { // always default to the latest version of the error formatter since we // need to return something switch (this.api_version) { case 1: default: sendReply(exception.getStatus(), serializer.formatErrorV1(exception)); } return; } if (hasQueryStringParam("json")) { final StringBuilder buf = new StringBuilder(10 + exception.getDetails().length()); buf.append("{\"err\":\""); HttpQuery.escapeJson(exception.getMessage(), buf); buf.append("\"}"); sendReply(HttpResponseStatus.BAD_REQUEST, buf); } else { sendReply(HttpResponseStatus.BAD_REQUEST, makePage("Bad Request", "Looks like it's your fault this time", "<blockquote>" + "<h1>Bad Request</h1>" + "Sorry but your request was rejected as being" + " invalid.<br/><br/>" + "The reason provided was:<blockquote>" + exception.getMessage() + "</blockquote></blockquote>")); } }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void internalError(final Exception cause) { logError("Internal Server Error on " + request().getUri(), cause); if (this.api_version > 0) { // always default to the latest version of the error formatter since we // need to return something switch (this.api_version) { case 1: default: sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR, serializer.formatErrorV1(cause)); } return; } ThrowableProxy tp = new ThrowableProxy(cause); tp.calculatePackagingData(); final String pretty_exc = ThrowableProxyUtil.asString(tp); tp = null; if (hasQueryStringParam("json")) { // 32 = 10 + some extra space as exceptions always have \t's to escape. final StringBuilder buf = new StringBuilder(32 + pretty_exc.length()); buf.append("{\"err\":\""); HttpQuery.escapeJson(pretty_exc, buf); buf.append("\"}"); sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR, buf); } else { sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR, makePage("Internal Server Error", "Houston, we have a problem", "<blockquote>" + "<h1>Internal Server Error</h1>" + "Oops, sorry but your request failed due to a" + " server error.<br/><br/>" + "Please try again in 30 seconds.<pre>" + pretty_exc + "</pre></blockquote>")); } }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void executeNSU() throws Exception { final DeferredGroupException dge = mock(DeferredGroupException.class); when(dge.getCause()).thenReturn(new NoSuchUniqueName("foo", "metrics")); when(query_result.configureFromQuery((TSQuery)any(), anyInt())) .thenReturn(Deferred.fromError(dge)); final HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.user"); rpc.execute(tsdb, query); assertEquals(HttpResponseStatus.BAD_REQUEST, query.response().getStatus()); final String json = query.response().getContent().toString(Charset.forName("UTF-8")); assertTrue(json.contains("No such name for 'foo': 'metrics'")); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
public void postQueryNoMetricBadRequest() throws Exception { final DeferredGroupException dge = mock(DeferredGroupException.class); when(dge.getCause()).thenReturn(new NoSuchUniqueName("foo", "metrics")); when(query_result.configureFromQuery((TSQuery)any(), anyInt())) .thenReturn(Deferred.fromError(dge)); HttpQuery query = NettyMocks.postQuery(tsdb, "/api/query", "{\"start\":1425440315306,\"queries\":" + "[{\"metric\":\"nonexistent\",\"aggregator\":\"sum\",\"rate\":true," + "\"rateOptions\":{\"counter\":false}}]}"); rpc.execute(tsdb, query); assertEquals(HttpResponseStatus.BAD_REQUEST, query.response().getStatus()); final String json = query.response().getContent().toString(Charset.forName("UTF-8")); assertTrue(json.contains("No such name for 'foo': 'metrics'")); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/74.html
vulnerable
protected boolean validateIssuerAudienceAndAzp(@NonNull JwtClaims claims, @NonNull String iss, @NonNull List<String> audiences, @NonNull String clientId, @NonNull OpenIdClientConfiguration openIdClientConfiguration) { if (openIdClientConfiguration.getIssuer().isPresent()) { Optional<URL> issuerOptional = openIdClientConfiguration.getIssuer(); if (issuerOptional.isPresent()) { String issuer = issuerOptional.get().toString(); return issuer.equalsIgnoreCase(iss) || audiences.contains(clientId) && validateAzp(claims, clientId, audiences); } } return false; }
0
Java
CWE-284
Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
vulnerable
public boolean matches(InetAddress socketAddress) { return socketAddress.isAnyLocalAddress() || socketAddress.isLoopbackAddress() || socketAddress.isLinkLocalAddress() || socketAddress.isSiteLocalAddress(); }
0
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable