code
stringlengths
12
2.05k
label
int64
0
1
programming_language
stringclasses
9 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
103
description
stringlengths
36
1.23k
url
stringlengths
36
48
label_name
stringclasses
2 values
public boolean check(String pArg) { if (patterns == null || patterns.size() == 0) { return true; } for (Pattern pattern : patterns) { if (pattern.matcher(pArg).matches()) { return true; } } return false; }
0
Java
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
vulnerable
protected PublicKey engineGeneratePublic( KeySpec keySpec) throws InvalidKeySpecException { if (keySpec instanceof DHPublicKeySpec) { try { return new BCDHPublicKey((DHPublicKeySpec)keySpec); } catch (IllegalArgumentException e) { throw new InvalidKeySpecException(e.getMessage(), e); } } return super.engineGeneratePublic(keySpec); }
1
Java
CWE-310
Cryptographic Issues
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
https://cwe.mitre.org/data/definitions/310.html
safe
public void testHeaderNameEndsWithControlChar1d() { testHeaderNameEndsWithControlChar(0x1d); }
1
Java
CWE-444
Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')
The product acts as an intermediary HTTP agent (such as a proxy or firewall) in the data flow between two entities such as a client and server, but it does not interpret malformed HTTP requests or responses in ways that are consistent with how the messages will be processed by those entities that are at the ultimate destination.
https://cwe.mitre.org/data/definitions/444.html
safe
public DHParameterSpec ike2048() { final BigInteger p = new BigInteger( "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74" + "020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f1437" + "4fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7ed" + "ee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf05" + "98da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb" + "9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3b" + "e39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf695581718" + "3995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff", 16); final BigInteger g = new BigInteger("2"); return new DHParameterSpec(p, g); }
1
Java
CWE-310
Cryptographic Issues
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
https://cwe.mitre.org/data/definitions/310.html
safe
public String toString() { if (query == null) { return path; } return path + "?" + query; }
0
Java
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
vulnerable
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Path path = ioService.get(new URI(request.getParameter("path"))); byte[] bytes = ioService.readAllBytes(path); response.setHeader("Content-Disposition", String.format("attachment; filename=%s;", path.getFileName().toString())); response.setContentType("application/octet-stream"); response.getOutputStream().write( bytes, 0, bytes.length); } catch (URISyntaxException e) { logger.error("Failed to download a file.", e); } }
0
Java
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
vulnerable
public void existingDocumentFromUIDeprecatedCheckEscaping() throws Exception { // current document = xwiki:Main.WebHome DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("Main"), "WebHome"); XWikiDocument document = mock(XWikiDocument.class); when(document.getDocumentReference()).thenReturn(documentReference); when(document.isNew()).thenReturn(false); when(document.getLocalReferenceMaxLength()).thenReturn(255); context.setDoc(document); // Submit from the UI space=X.Y&page=Z when(mockRequest.getParameter("space")).thenReturn("X.Y"); when(mockRequest.getParameter("page")).thenReturn("Z"); // Run the action String result = action.render(context); // The tests are below this line! // Verify null is returned (this means the response has been returned) assertNull(result); // Note1: The space parameter was previously considered as space name, not space reference, so it is escaped. // Note2: We are creating X\.Y.Z since the deprecated parameters were creating terminal documents by default. verify(mockURLFactory).createURL("X\\.Y", "Z", "edit", "template=&parent=Main.WebHome&title=Z", null, "xwiki", context); }
0
Java
CWE-862
Missing Authorization
The software 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
protected void tearDown() throws Exception { SecretHelper.set(null); super.tearDown(); }
1
Java
NVD-CWE-noinfo
null
null
null
safe
private byte[] decodeAndInflate(String encodedRequest) throws SAMLException { byte[] bytes = Base64.getMimeDecoder().decode(encodedRequest); Inflater inflater = new Inflater(true); inflater.setInput(bytes); inflater.finished(); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] result = new byte[bytes.length]; while (!inflater.finished()) { int length = inflater.inflate(result); if (length > 0) { baos.write(result, 0, length); } } return baos.toByteArray(); } catch (DataFormatException e) { throw new SAMLException("Invalid AuthnRequest. Inflating the bytes failed.", e); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new AESEngine())); }
1
Java
CWE-310
Cryptographic Issues
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
https://cwe.mitre.org/data/definitions/310.html
safe
void multipleValuesPerNameShouldBeAllowed() { final HttpHeadersBase headers = newEmptyHeaders(); headers.add("name", "value1"); headers.add("name", "value2"); headers.add("name", "value3"); assertThat(headers.size()).isEqualTo(3); final List<String> values = headers.getAll("name"); assertThat(values).hasSize(3) .containsExactly("value1", "value2", "value3"); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
public static byte[] serializeToBytes(final Object payload) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); serializeToStream(bos, payload); return bos.toByteArray(); }
0
Java
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
private ZonedDateTime convertToZonedDateTime(XMLGregorianCalendar cal) { return cal != null ? cal.toGregorianCalendar().toZonedDateTime() : null; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
private ServiceStat getRateLimitOpCountStat() throws Throwable { URI managementServiceUri = this.host.getManagementServiceUri(); ServiceStat stats = this.host.getServiceStats(managementServiceUri) .get(ServiceHostManagementService.STAT_NAME_RATE_LIMITED_OP_COUNT); return stats; }
1
Java
CWE-732
Incorrect Permission Assignment for Critical Resource
The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
https://cwe.mitre.org/data/definitions/732.html
safe
public void testInvalidGroupId(final String groupId, final boolean mustFail) { adminPage(); findElementByLink("Configure Users, Groups and On-Call Roles").click(); findElementByLink("Configure Groups").click(); findElementByLink("Add new group").click(); enterText(By.id("groupName"), groupId); enterText(By.id("groupComment"), "SmokeTestComment"); findElementByXpath("//button[@type='submit' and text()='OK']").click(); if (mustFail) { try { final Alert alert = wait.withTimeout(Duration.of(5, ChronoUnit.SECONDS)).until(ExpectedConditions.alertIsPresent()); alert.dismiss(); } catch (final Exception e) { LOG.debug("Got an exception waiting for a 'invalid group ID' alert.", e); throw e; } } else { wait.until(ExpectedConditions.elementToBeClickable(By.name("finish"))); } }
1
Java
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
safe
public static int version() { return 1202204; }
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 Optional<CorsOriginConfiguration> convert(Object object, Class<CorsOriginConfiguration> targetType, ConversionContext context) { CorsOriginConfiguration configuration = new CorsOriginConfiguration(); if (object instanceof Map) { Map mapConfig = (Map) object; ConvertibleValues<Object> convertibleValues = new ConvertibleValuesMap<>(mapConfig); convertibleValues .get(ALLOWED_ORIGINS, Argument.listOf(String.class)) .ifPresent(configuration::setAllowedOrigins); convertibleValues .get(ALLOWED_METHODS, Argument.listOf(HttpMethod.class)) .ifPresent(configuration::setAllowedMethods); convertibleValues .get(ALLOWED_HEADERS, Argument.listOf(String.class)) .ifPresent(configuration::setAllowedHeaders); convertibleValues .get(EXPOSED_HEADERS, Argument.listOf(String.class)) .ifPresent(configuration::setExposedHeaders); convertibleValues .get(ALLOW_CREDENTIALS, Boolean.class) .ifPresent(configuration::setAllowCredentials); convertibleValues .get(MAX_AGE, Long.class) .ifPresent(configuration::setMaxAge); } return Optional.of(configuration); }
0
Java
CWE-400
Uncontrolled Resource Consumption
The software 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
setImmediate(() => { if (!this.pendingPublishRequestCount) { return; } const starving_subscription = this._find_starving_subscription(); if (starving_subscription) { doDebug && debugLog(chalk.bgWhite.red("feeding most late subscription subscriptionId = "), starving_subscription.id); starving_subscription.process_subscription(); } });
0
Java
CWE-770
Allocation of Resources Without Limits or Throttling
The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
https://cwe.mitre.org/data/definitions/770.html
vulnerable
public void testInvalidGroupId(final String groupId, final boolean mustFail) { adminPage(); findElementByLink("Configure Users, Groups and On-Call Roles").click(); findElementByLink("Configure Groups").click(); findElementByLink("Add new group").click(); enterText(By.id("groupName"), groupId); enterText(By.id("groupComment"), "SmokeTestComment"); findElementByXpath("//button[@type='submit' and text()='OK']").click(); if (mustFail) { try { final Alert alert = wait.withTimeout(Duration.of(5, ChronoUnit.SECONDS)).until(ExpectedConditions.alertIsPresent()); alert.dismiss(); } catch (final Exception e) { LOG.debug("Got an exception waiting for a 'invalid group ID' alert.", e); throw e; } } else { wait.until(ExpectedConditions.elementToBeClickable(By.name("finish"))); } }
1
Java
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
safe
public SecretRewriter() throws GeneralSecurityException { cipher = Secret.getCipher("AES"); key = HistoricalSecrets.getLegacyKey(); }
1
Java
CWE-326
Inadequate Encryption Strength
The software stores or transmits sensitive data using an encryption scheme that is theoretically sound, but is not strong enough for the level of protection required.
https://cwe.mitre.org/data/definitions/326.html
safe
public void complexExample() throws Exception { assertThat(ConstraintViolations.format(validator.validate(new ComplexExample()))) .containsExactlyInAnyOrder( FAILED_RESULT + "1", FAILED_RESULT + "2", FAILED_RESULT + "3" ); assertThat(TestLoggerFactory.getAllLoggingEvents()) .isEmpty(); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
private String marshallToString(Document document) throws TransformerException { StringWriter sw = new StringWriter(); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(new DOMSource(document), new StreamResult(sw)); return sw.toString(); }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public <T> JAXBElement<T> unmarshal(Source source, Class<T> declaredType) throws JAXBException { if(source instanceof SAXSource) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xmlReader = sp.getXMLReader(); xmlReader.setFeature("http://xml.org/sax/features/validation", false); xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", false); xmlReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false); xmlReader.setFeature("http://xml.org/sax/features/namespaces", true); ((SAXSource) source).setXMLReader(xmlReader); return delegate.unmarshal(source, declaredType); } catch (SAXException e) { throw new JAXBException(e); } catch (ParserConfigurationException e) { throw new JAXBException(e); } } throw new UnsupportedOperationException(errorMessage("Source, Class<T>")); }
1
Java
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
public int decryptWithAd(byte[] ad, byte[] ciphertext, int ciphertextOffset, byte[] plaintext, int plaintextOffset, int length) throws ShortBufferException, BadPaddingException { int space; if (ciphertextOffset > ciphertext.length) space = 0; else space = ciphertext.length - ciphertextOffset; if (length > space) throw new ShortBufferException(); if (plaintextOffset > plaintext.length) space = 0; else space = plaintext.length - plaintextOffset; if (!haskey) { // The key is not set yet - return the ciphertext as-is. if (length > space) throw new ShortBufferException(); if (plaintext != ciphertext || plaintextOffset != ciphertextOffset) System.arraycopy(ciphertext, ciphertextOffset, plaintext, plaintextOffset, length); return length; } if (length < 16) Noise.throwBadTagException(); int dataLen = length - 16; if (dataLen > space) throw new ShortBufferException(); setup(ad); poly.update(ciphertext, ciphertextOffset, dataLen); finish(ad, dataLen); int temp = 0; for (int index = 0; index < 16; ++index) temp |= (polyKey[index] ^ ciphertext[ciphertextOffset + dataLen + index]); if ((temp & 0xFF) != 0) Noise.throwBadTagException(); encrypt(ciphertext, ciphertextOffset, plaintext, plaintextOffset, dataLen); return dataLen; }
0
Java
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
public void testExcludesMidUri() { final Collection<String> patterns = new ArrayList<String>() {{ add( "file://**" ); add( "**/repo/**" ); }}; Assert.assertTrue( excludes( patterns, URI.create( "file:///Users/home" ) ) ); Assert.assertFalse( excludes( patterns, URI.create( "git://antpathmatcher" ) ) ); Assert.assertTrue( excludes( patterns, URI.create( "git://master@antpathmatcher/repo/sss" ) ) ); }
1
Java
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
private File tempFile() throws IOException { String newpostfix; String diskFilename = getDiskFilename(); if (diskFilename != null) { newpostfix = '_' + diskFilename; } else { newpostfix = getPostfix(); } File tmpFile; if (getBaseDirectory() == null) { // create a temporary file tmpFile = File.createTempFile(getPrefix(), newpostfix); } else { tmpFile = File.createTempFile(getPrefix(), newpostfix, new File( getBaseDirectory())); } if (deleteOnExit()) { // See https://github.com/netty/netty/issues/10351 DeleteFileOnExitHook.add(tmpFile.getPath()); } return tmpFile; }
0
Java
CWE-378
Creation of Temporary File With Insecure Permissions
Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.
https://cwe.mitre.org/data/definitions/378.html
vulnerable
public void testHeaderNameStartsWithControlChar0c() { testHeaderNameStartsWithControlChar(0x0c); }
1
Java
CWE-444
Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')
The product acts as an intermediary HTTP agent (such as a proxy or firewall) in the data flow between two entities such as a client and server, but it does not interpret malformed HTTP requests or responses in ways that are consistent with how the messages will be processed by those entities that are at the ultimate destination.
https://cwe.mitre.org/data/definitions/444.html
safe
public EntityResolver getEntityResolver() { return entityResolver; }
1
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
safe
public void testEnsurePublicXYCoordinatesOnCurve() throws Exception { try { new ECKey( ECKey.Curve.P_256, ExampleKeyP384Alt.X, // on diff curve ExampleKeyP384Alt.Y, // on diff curve null, null, null, null, null, null, null, null, null); fail(); } catch (IllegalArgumentException e) { assertEquals("Invalid EC JWK: The 'x' and 'y' public coordinates are not on the P-256 curve", e.getMessage()); } try { new ECKey( ECKey.Curve.P_256, ExampleKeyP384Alt.X, // on diff curve ExampleKeyP384Alt.Y, // on diff curve ExampleKeyP256.D, // private D coordinate null, null, null, null, null, null, null, null, null); fail(); } catch (IllegalArgumentException e) { assertEquals("Invalid EC JWK: The 'x' and 'y' public coordinates are not on the P-256 curve", e.getMessage()); } }
1
Java
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
safe
public Map<String, String> handleCorsPreflightRequest(String pOrigin, String pRequestHeaders) { Map<String,String> ret = new HashMap<String, String>(); if (pOrigin != null && backendManager.isCorsAccessAllowed(pOrigin)) { // CORS is allowed, we set exactly the origin in the header, so there are no problems with authentication ret.put("Access-Control-Allow-Origin","null".equals(pOrigin) ? "*" : pOrigin); if (pRequestHeaders != null) { ret.put("Access-Control-Allow-Headers",pRequestHeaders); } // Fix for CORS with authentication (#104) ret.put("Access-Control-Allow-Credentials","true"); // Allow for one year. Changes in access.xml are reflected directly in the cors request itself ret.put("Access-Control-Allow-Max-Age","" + 3600 * 24 * 365); } return ret; }
0
Java
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
vulnerable
public JWECryptoParts encrypt(final JWEHeader header, final byte[] clearText) throws JOSEException { JWEAlgorithm alg = header.getAlgorithm(); if (! alg.equals(JWEAlgorithm.DIR)) { throw new JOSEException(AlgorithmSupportMessage.unsupportedJWEAlgorithm(alg, SUPPORTED_ALGORITHMS)); } // Check key length matches encryption method EncryptionMethod enc = header.getEncryptionMethod(); if (enc.cekBitLength() != ByteUtils.bitLength(getKey().getEncoded())) { throw new KeyLengthException(enc.cekBitLength(), enc); } final Base64URL encryptedKey = null; // The second JWE part return ContentCryptoProvider.encrypt(header, clearText, getKey(), encryptedKey, getJCAContext()); }
0
Java
CWE-345
Insufficient Verification of Data Authenticity
The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.
https://cwe.mitre.org/data/definitions/345.html
vulnerable
public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { try { if (isDebugEnabled()) { debugCode( "getSource(" + (sourceClass != null ? sourceClass.getSimpleName() + ".class" : "null") + ')'); } checkReadable(); if (sourceClass == null || sourceClass == DOMSource.class) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); return (T) new DOMSource(dbf.newDocumentBuilder().parse(new InputSource(value.getInputStream()))); } else if (sourceClass == SAXSource.class) { return (T) new SAXSource(new InputSource(value.getInputStream())); } else if (sourceClass == StAXSource.class) { XMLInputFactory xif = XMLInputFactory.newInstance(); return (T) new StAXSource(xif.createXMLStreamReader(value.getInputStream())); } else if (sourceClass == StreamSource.class) { return (T) new StreamSource(value.getInputStream()); } throw unsupported(sourceClass.getName()); } catch (Exception e) { throw logAndConvert(e); } }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
public void testSecurity49Upgrade() throws Exception { jenkins.setSecurityRealm(createDummySecurityRealm()); User u = User.get("foo"); String historicalInitialValue = Util.getDigestOf(Jenkins.getInstance().getSecretKey() + ":" + u.getId()); // we won't accept historically used initial value as it may be compromised ApiTokenProperty t = new ApiTokenProperty(historicalInitialValue); u.addProperty(t); String apiToken1 = t.getApiToken(); assertFalse(apiToken1.equals(Util.getDigestOf(historicalInitialValue))); // the replacement for the compromised value must be consistent and cannot be random ApiTokenProperty t2 = new ApiTokenProperty(historicalInitialValue); u.addProperty(t2); assertEquals(apiToken1,t2.getApiToken()); // any other value is OK. those are changed values t = new ApiTokenProperty(historicalInitialValue+"somethingElse"); u.addProperty(t); assertTrue(t.getApiToken().equals(Util.getDigestOf(historicalInitialValue+"somethingElse"))); }
1
Java
NVD-CWE-noinfo
null
null
null
safe
protected void run() throws IOException, InterruptedException { if(!getSecretKey().equals(in.readUTF())) { error(out, "Unauthorized access"); return; } final String nodeName = in.readUTF(); SlaveComputer computer = (SlaveComputer) Jenkins.getInstance().getComputer(nodeName); if(computer==null) { error(out, "No such slave: "+nodeName); return; } if(computer.getChannel()!=null) { error(out, nodeName+" is already connected to this master. Rejecting this connection."); return; } out.println(Engine.GREETING_SUCCESS); jnlpConnect(computer); }
0
Java
NVD-CWE-noinfo
null
null
null
vulnerable
public Player(String title, ISkinParam skinParam, TimingRuler ruler, boolean compact) { this.skinParam = skinParam; this.compact = compact; this.ruler = ruler; this.title = Display.getWithNewlines(title); }
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 testGetShellCommandLineBash_WithWorkingDirectory() throws Exception { Commandline cmd = new Commandline( new BourneShell() ); cmd.setExecutable( "/bin/echo" ); cmd.addArguments( new String[] { "hello world" } ); File root = File.listRoots()[0]; File workingDirectory = new File( root, "path with spaces" ); cmd.setWorkingDirectory( workingDirectory ); String[] shellCommandline = cmd.getShellCommandline(); assertEquals( "Command line size", 3, shellCommandline.length ); assertEquals( "/bin/sh", shellCommandline[0] ); assertEquals( "-c", shellCommandline[1] ); String expectedShellCmd = "cd '" + root.getAbsolutePath() + "path with spaces' && '/bin/echo' 'hello world'"; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { expectedShellCmd = "cd '" + root.getAbsolutePath() + "path with spaces' && '\\bin\\echo' 'hello world'"; } assertEquals( expectedShellCmd, shellCommandline[2] ); }
1
Java
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
safe
private File tempFile() throws IOException { String newpostfix; String diskFilename = getDiskFilename(); if (diskFilename != null) { newpostfix = '_' + diskFilename; } else { newpostfix = getPostfix(); } File tmpFile; if (getBaseDirectory() == null) { // create a temporary file tmpFile = PlatformDependent.createTempFile(getPrefix(), newpostfix, null); } else { tmpFile = PlatformDependent.createTempFile(getPrefix(), newpostfix, new File( getBaseDirectory())); } if (deleteOnExit()) { // See https://github.com/netty/netty/issues/10351 DeleteFileOnExitHook.add(tmpFile.getPath()); } return tmpFile; }
1
Java
CWE-378
Creation of Temporary File With Insecure Permissions
Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.
https://cwe.mitre.org/data/definitions/378.html
safe
public void addViolation(String propertyName, String key, String message) { violationOccurred = true; String messageTemplate = escapeEl(message); context.buildConstraintViolationWithTemplate(messageTemplate) .addPropertyNode(propertyName) .addBeanNode().inIterable().atKey(key) .addConstraintViolation(); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
public String getExecutable() { if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { return super.getExecutable(); } return unifyQuotes( super.getExecutable()); }
0
Java
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
public void translate(ServerPlayerHealthPacket packet, GeyserSession session) { SessionPlayerEntity entity = session.getPlayerEntity(); int health = (int) Math.ceil(packet.getHealth()); SetHealthPacket setHealthPacket = new SetHealthPacket(); setHealthPacket.setHealth(health); session.sendUpstreamPacket(setHealthPacket); entity.setHealth(packet.getHealth()); UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket(); List<AttributeData> attributes = attributesPacket.getAttributes(); AttributeData healthAttribute = entity.createHealthAttribute(); entity.getAttributes().put(GeyserAttributeType.HEALTH, healthAttribute); attributes.add(healthAttribute); AttributeData hungerAttribute = GeyserAttributeType.HUNGER.getAttribute(packet.getFood()); entity.getAttributes().put(GeyserAttributeType.HUNGER, hungerAttribute); attributes.add(hungerAttribute); AttributeData saturationAttribute = GeyserAttributeType.SATURATION.getAttribute(packet.getSaturation()); entity.getAttributes().put(GeyserAttributeType.SATURATION, saturationAttribute); attributes.add(saturationAttribute); attributesPacket.setRuntimeEntityId(entity.getGeyserId()); session.sendUpstreamPacket(attributesPacket); }
0
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
public Element handle(Element request, Map<String, Object> context) throws ServiceException { ZimbraSoapContext zsc = getZimbraSoapContext(context); Account account = getRequestedAccount(getZimbraSoapContext(context)); if (!canAccessAccount(zsc, account)) throw ServiceException.PERM_DENIED("can not access account"); String name = request.getAttribute(AccountConstants.E_NAME); String typeStr = request.getAttribute(AccountConstants.A_TYPE, "account"); GalSearchType type = GalSearchType.fromString(typeStr); boolean needCanExpand = request.getAttributeBool(AccountConstants.A_NEED_EXP, false); String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null); GalSearchParams params = new GalSearchParams(account, zsc); params.setType(type); params.setRequest(request); params.setQuery(name); params.setLimit(account.getContactAutoCompleteMaxResults()); params.setNeedCanExpand(needCanExpand); params.setResponseName(AccountConstants.AUTO_COMPLETE_GAL_RESPONSE); if (galAcctId != null) params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId)); GalSearchControl gal = new GalSearchControl(params); gal.autocomplete(); return params.getResultCallback().getResponse(); }
0
Java
CWE-862
Missing Authorization
The software 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 static void square(int[] x, int[] zz) { long x_0 = x[0] & M; long zz_1; int c = 0, w; { int i = 3, j = 8; do { long xVal = (x[i--] & M); long p = xVal * xVal; zz[--j] = (c << 31) | (int)(p >>> 33); zz[--j] = (int)(p >>> 1); c = (int)p; } while (i > 0); { long p = x_0 * x_0; zz_1 = ((c << 31) & M) | (p >>> 33); zz[0] = (int)p; c = (int)(p >>> 32) & 1; } } long x_1 = x[1] & M; long zz_2 = zz[2] & M; { zz_1 += x_1 * x_0; w = (int)zz_1; zz[1] = (w << 1) | c; c = w >>> 31; zz_2 += zz_1 >>> 32; } long x_2 = x[2] & M; long zz_3 = zz[3] & M; long zz_4 = zz[4] & M; { zz_2 += x_2 * x_0; w = (int)zz_2; zz[2] = (w << 1) | c; c = w >>> 31; zz_3 += (zz_2 >>> 32) + x_2 * x_1; zz_4 += zz_3 >>> 32; zz_3 &= M; } long x_3 = x[3] & M; long zz_5 = (zz[5] & M) + (zz_4 >>> 32); zz_4 &= M; long zz_6 = (zz[6] & M) + (zz_5 >>> 32); zz_5 &= M; { zz_3 += x_3 * x_0; w = (int)zz_3; zz[3] = (w << 1) | c; c = w >>> 31; zz_4 += (zz_3 >>> 32) + x_3 * x_1; zz_5 += (zz_4 >>> 32) + x_3 * x_2; zz_6 += zz_5 >>> 32; zz_5 &= M; } w = (int)zz_4; zz[4] = (w << 1) | c; c = w >>> 31; w = (int)zz_5; zz[5] = (w << 1) | c; c = w >>> 31; w = (int)zz_6; zz[6] = (w << 1) | c; c = w >>> 31; w = zz[7] + (int)(zz_6 >>> 32); zz[7] = (w << 1) | c; }
1
Java
CWE-19
Data Processing Errors
Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.
https://cwe.mitre.org/data/definitions/19.html
safe
public void multipleTestingOfSameClass() throws Exception { assertThat(ConstraintViolations.format(validator.validate(new CorrectExample()))) .isEmpty(); assertThat(ConstraintViolations.format(validator.validate(new CorrectExample()))) .isEmpty(); assertThat(TestLoggerFactory.getAllLoggingEvents()) .isEmpty(); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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 addHandler(String path, ElementHandler handler) { getDispatchHandler().addHandler(path, handler); }
1
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
safe
public AsciiString generateSessionId() { ThreadLocalRandom random = ThreadLocalRandom.current(); UUID uuid = new UUID(random.nextLong(), random.nextLong()); return AsciiString.of(uuid.toString()); }
0
Java
CWE-338
Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong.
https://cwe.mitre.org/data/definitions/338.html
vulnerable
public void encodeByteArray2() { Packet<byte[]> packet = new Packet<>(Parser.BINARY_EVENT); packet.data = new byte[2]; packet.id = 0; packet.nsp = "/"; Helpers.testBin(packet); }
0
Java
CWE-476
NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
https://cwe.mitre.org/data/definitions/476.html
vulnerable
public RFC3211Wrap() { super(new RFC3211WrapEngine(new AESEngine()), 16); }
1
Java
CWE-310
Cryptographic Issues
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
https://cwe.mitre.org/data/definitions/310.html
safe
public void authorizeRequest(Operation op) { op.complete(); }
0
Java
CWE-732
Incorrect Permission Assignment for Critical Resource
The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
https://cwe.mitre.org/data/definitions/732.html
vulnerable
static AlgorithmMode resolveAlgorithmMode(final JWEAlgorithm alg) throws JOSEException { if (alg.equals(JWEAlgorithm.ECDH_ES)) { return AlgorithmMode.DIRECT; } else if (alg.equals(JWEAlgorithm.ECDH_ES_A128KW) || alg.equals(JWEAlgorithm.ECDH_ES_A192KW) || alg.equals(JWEAlgorithm.ECDH_ES_A256KW)) { return AlgorithmMode.KW; } else { throw new JOSEException(AlgorithmSupportMessage.unsupportedJWEAlgorithm( alg, ECDHCryptoProvider.SUPPORTED_ALGORITHMS)); } }
1
Java
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
safe
public void translate(SetLocalPlayerAsInitializedPacket packet, GeyserSession session) { if (session.getPlayerEntity().getGeyserId() == packet.getRuntimeEntityId()) { if (!session.getUpstream().isInitialized()) { session.getUpstream().setInitialized(true); session.login(); for (PlayerEntity entity : session.getEntityCache().getEntitiesByType(PlayerEntity.class)) { if (!entity.isValid()) { SkinManager.requestAndHandleSkinAndCape(entity, session, null); entity.sendPlayer(session); } } // Send Skulls for (PlayerEntity entity : session.getSkullCache().values()) { entity.spawnEntity(session); SkullSkinManager.requestAndHandleSkin(entity, session, (skin) -> { entity.getMetadata().getFlags().setFlag(EntityFlag.INVISIBLE, false); entity.updateBedrockMetadata(session); }); } } } }
0
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
protected Details authenticate(String username, String password) throws AuthenticationException { Details u = loadUserByUsername(username); if (!u.isPasswordCorrect(password)) throw new BadCredentialsException("Failed to login as "+username); return u; }
0
Java
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
public void shouldNotIncludeCommitFromAnotherBranchInGetLatestModifications() throws Exception { Modification lastCommit = hgCommand.latestOneModificationAsModifications().get(0); makeACommitToSecondBranch(); hg(workingDirectory, "pull").runOrBomb(null); Modification actual = hgCommand.latestOneModificationAsModifications().get(0); assertThat(actual, is(lastCommit)); assertThat(actual.getComment(), is(lastCommit.getComment())); }
0
Java
CWE-77
Improper Neutralization of Special Elements used in a Command ('Command Injection')
The software constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/77.html
vulnerable
protected boolean validateAccess( final Path path, final HttpServletResponse response ) { if ( !AntPathMatcher.filter( includes, excludes, path ) ) { logger.error( "Invalid credentials to path." ); try { response.sendError( SC_FORBIDDEN ); } catch ( Exception ex ) { logger.error( ex.getMessage() ); } return false; } return true; }
1
Java
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
public SslClientCertificateCredential(File certificate, String password) throws IOException { this.password = Scrambler.scramble(password); this.certificate = Secret.fromString(new String(Base64.encode(FileUtils.readFileToByteArray(certificate)))); }
0
Java
CWE-255
Credentials Management Errors
Weaknesses in this category are related to the management of credentials.
https://cwe.mitre.org/data/definitions/255.html
vulnerable
void testDecodePath(boolean isPathParam) throws Exception { final Function<String, String> decodeFunc; if (isPathParam) { decodeFunc = ArmeriaHttpUtil::decodePathParam; } else { decodeFunc = ArmeriaHttpUtil::decodePath; } // Fast path final String pathThatDoesNotNeedDecode = "/foo_bar_baz"; assertThat(decodeFunc.apply(pathThatDoesNotNeedDecode)).isSameAs(pathThatDoesNotNeedDecode); // Slow path assertThat(decodeFunc.apply("/foo%20bar\u007fbaz")).isEqualTo("/foo bar\u007fbaz"); assertThat(decodeFunc.apply("/%C2%A2")).isEqualTo("/¢"); // Valid UTF-8 sequence assertThat(decodeFunc.apply("/%20\u0080")).isEqualTo("/ �"); // Unallowed character assertThat(decodeFunc.apply("/%")).isEqualTo("/�"); // No digit assertThat(decodeFunc.apply("/%1")).isEqualTo("/�"); // Only a single digit assertThat(decodeFunc.apply("/%G0")).isEqualTo("/�"); // First digit is not hex. assertThat(decodeFunc.apply("/%0G")).isEqualTo("/�"); // Second digit is not hex. assertThat(decodeFunc.apply("/%C3%28")).isEqualTo("/�("); // Invalid UTF-8 sequence // %2F (/) must be decoded only for path parameters. if (isPathParam) { assertThat(decodeFunc.apply("/%2F")).isEqualTo("//"); } else { assertThat(decodeFunc.apply("/%2F")).isEqualTo("/%2F"); } }
1
Java
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
safe
private BigInteger validate(BigInteger y, DHParameters dhParams) { if (y == null) { throw new NullPointerException("y value cannot be null"); } // TLS check if (y.compareTo(TWO) < 0 || y.compareTo(dhParams.getP().subtract(TWO)) > 0) { throw new IllegalArgumentException("invalid DH public key"); } if (dhParams.getQ() != null) { if (ONE.equals(y.modPow(dhParams.getQ(), dhParams.getP()))) { return y; } throw new IllegalArgumentException("Y value does not appear to be in correct group"); } else { return y; // we can't validate without Q. } }
1
Java
CWE-310
Cryptographic Issues
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
https://cwe.mitre.org/data/definitions/310.html
safe
public Document read(String systemId) throws DocumentException { InputSource source = new InputSource(systemId); if (this.encoding != null) { source.setEncoding(this.encoding); } return read(source); }
1
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
safe
void setAllShouldOverwriteSomeAndLeaveOthersUntouched() { final HttpHeadersBase h1 = newEmptyHeaders(); h1.add("name1", "value1"); h1.add("name2", "value2"); h1.add("name2", "value3"); h1.add("name3", "value4"); final HttpHeadersBase h2 = newEmptyHeaders(); h2.add("name1", "value5"); h2.add("name2", "value6"); h2.add("name1", "value7"); final HttpHeadersBase expected = newEmptyHeaders(); expected.add("name1", "value5"); expected.add("name2", "value6"); expected.add("name1", "value7"); expected.add("name3", "value4"); h1.set(h2); assertThat(h1).isEqualTo(expected); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
private SecretKey getKey() { if (key==null) { synchronized (this) { if (key==null) { try { byte[] encoded = load(); if (encoded==null) { KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM); SecretKey key = kg.generateKey(); store(encoded=key.getEncoded()); } key = new SecretKeySpec(encoded,ALGORITHM); } catch (IOException e) { throw new Error("Failed to load the key: "+getId(),e); } catch (NoSuchAlgorithmException e) { throw new Error("Failed to load the key: "+getId(),e); } } } } return key; }
1
Java
NVD-CWE-noinfo
null
null
null
safe
private static RememberMeServices createRememberMeService(UserDetailsService uds) { // create our default TokenBasedRememberMeServices, which depends on the availability of the secret key TokenBasedRememberMeServices2 rms = new TokenBasedRememberMeServices2(); rms.setUserDetailsService(uds); /* TokenBasedRememberMeServices needs to be used in conjunction with RememberMeAuthenticationProvider, and both needs to use the same key (this is a reflection of a poor design in AcgeiSecurity, if you ask me) and various security plugins have its own groovy script that configures them. So if we change this, it creates a painful situation for those plugins by forcing them to choose to work with earlier version of Jenkins or newer version of Jenkins, and not both. So we keep this here. */ rms.setKey(Jenkins.getInstance().getSecretKey()); rms.setParameter("remember_me"); // this is the form field name in login.jelly return rms; }
1
Java
NVD-CWE-noinfo
null
null
null
safe
public void testCurveCheckNegative_P256_attackPt2() throws Exception { // The malicious JWE contains a public key with order 2447 String maliciousJWE = "eyJhbGciOiJFQ0RILUVTK0ExMjhLVyIsImVuYyI6IkExMjhDQkMtSFMyNTYiLCJlcGsiOnsia3R5IjoiRUMiLCJ4IjoiWE9YR1E5XzZRQ3ZCZzN1OHZDSS1VZEJ2SUNBRWNOTkJyZnFkN3RHN29RNCIsInkiOiJoUW9XTm90bk56S2x3aUNuZUprTElxRG5UTnc3SXNkQkM1M1ZVcVZqVkpjIiwiY3J2IjoiUC0yNTYifX0.UGb3hX3ePAvtFB9TCdWsNkFTv9QWxSr3MpYNiSBdW630uRXRBT3sxw.6VpU84oMob16DxOR98YTRw.y1UslvtkoWdl9HpugfP0rSAkTw1xhm_LbK1iRXzGdpYqNwIG5VU33UBpKAtKFBoA1Kk_sYtfnHYAvn-aes4FTg.UZPN8h7FcvA5MIOq-Pkj8A"; JWEObject jweObject = JWEObject.parse(maliciousJWE); ECPublicKey ephemeralPublicKey = jweObject.getHeader().getEphemeralPublicKey().toECPublicKey(); ECPrivateKey privateKey = generateECPrivateKey(ECKey.Curve.P_256); try { ECDH.ensurePointOnCurve(ephemeralPublicKey, privateKey); fail(); } catch (JOSEException e) { assertEquals("Invalid ephemeral public key: Point not on expected curve", e.getMessage()); } }
0
Java
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
vulnerable
public MultiMap set(String name, Iterable<String> values) { HttpUtils.validateHeader(name, values); headers.set(toLowerCase(name), values); return this; }
1
Java
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
public int encryptWithAd(byte[] ad, byte[] plaintext, int plaintextOffset, byte[] ciphertext, int ciphertextOffset, int length) throws ShortBufferException { int space; if (ciphertextOffset > ciphertext.length) space = 0; else space = ciphertext.length - ciphertextOffset; if (!haskey) { // The key is not set yet - return the plaintext as-is. if (length > space) throw new ShortBufferException(); if (plaintext != ciphertext || plaintextOffset != ciphertextOffset) System.arraycopy(plaintext, plaintextOffset, ciphertext, ciphertextOffset, length); return length; } if (space < 16 || length > (space - 16)) throw new ShortBufferException(); setup(ad); encryptCTR(plaintext, plaintextOffset, ciphertext, ciphertextOffset, length); ghash.update(ciphertext, ciphertextOffset, length); ghash.pad(ad != null ? ad.length : 0, length); ghash.finish(ciphertext, ciphertextOffset + length, 16); for (int index = 0; index < 16; ++index) ciphertext[ciphertextOffset + length + index] ^= hashKey[index]; return length + 16; }
0
Java
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
public void qnameFail1() { QName.get("ns:elem:ent", "http://example.com/namespace"); }
1
Java
CWE-91
XML Injection (aka Blind XPath Injection)
The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.
https://cwe.mitre.org/data/definitions/91.html
safe
public void newDocumentWebHomeFromURLTemplateProviderSpecifiedButNotAllowed() throws Exception { // new document = xwiki:X.Y.WebHome DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("X", "Y"), "WebHome"); XWikiDocument document = mock(XWikiDocument.class); when(document.getDocumentReference()).thenReturn(documentReference); when(document.isNew()).thenReturn(true); when(document.getLocalReferenceMaxLength()).thenReturn(255); context.setDoc(document); // Specifying a template provider in the URL: templateprovider=XWiki.MyTemplateProvider String templateProviderFullName = "XWiki.MyTemplateProvider"; when(mockRequest.getParameter("templateprovider")).thenReturn(templateProviderFullName); // Mock 1 existing template provider mockExistingTemplateProviders(templateProviderFullName, new DocumentReference("xwiki", Arrays.asList("XWiki"), "MyTemplateProvider"), Arrays.asList("AnythingButX")); // Run the action String result = action.render(context); // The tests are below this line! // Verify that the create template is rendered, so the UI is displayed for the user to see the error. assertEquals("create", result); // Check that the exception is properly set in the context for the UI to display. XWikiException exception = (XWikiException) this.oldcore.getScriptContext().getAttribute("createException"); assertNotNull(exception); assertEquals(XWikiException.ERROR_XWIKI_APP_TEMPLATE_NOT_AVAILABLE, exception.getCode()); // We should not get this far so no redirect should be done, just the template will be rendered. verify(mockURLFactory, never()).createURL(any(), any(), any(), any(), any(), any(), any(XWikiContext.class)); }
0
Java
CWE-862
Missing Authorization
The software 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 void testMatchUseNotSpecifiedOrSignature() { JWKMatcher matcher = new JWKMatcher.Builder().keyUses(KeyUse.SIGNATURE, null).build(); assertTrue(matcher.matches(new RSAKey.Builder(new Base64URL("n"), new Base64URL("e")).keyID("1").keyUse(KeyUse.SIGNATURE).build())); assertTrue(matcher.matches(new ECKey.Builder(ECKey.Curve.P_256, new Base64URL("x"), new Base64URL("y")).keyID("2").build())); assertFalse(matcher.matches(new ECKey.Builder(ECKey.Curve.P_256, new Base64URL("x"), new Base64URL("y")).keyID("3").keyUse(KeyUse.ENCRYPTION).build())); assertEquals("use=[sig, null]", matcher.toString()); }
0
Java
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
vulnerable
public static void writeObject(XStream xStream, OutputStream os, Object obj) { try(OutputStreamWriter osw = new OutputStreamWriter(os, ENCODING)) { String data = xStream.toXML(obj); data = "<?xml version=\"1.0\" encoding=\"" + ENCODING + "\"?>\n" + data; // give a decent header with the encoding used osw.write(data); osw.flush(); } catch (Exception e) { throw new OLATRuntimeException(XStreamHelper.class, "Could not write object to stream.", e); } }
0
Java
CWE-91
XML Injection (aka Blind XPath Injection)
The software does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.
https://cwe.mitre.org/data/definitions/91.html
vulnerable
void testSetOrdersPseudoHeadersCorrectly() { final HttpHeadersBase headers = newHttp2Headers(); final HttpHeadersBase other = newEmptyHeaders(); other.add("name2", "value2"); other.add("name3", "value3"); other.add("name4", "value4"); other.authority("foo"); final int headersSizeBefore = headers.size(); headers.set(other); verifyPseudoHeadersFirst(headers); verifyAllPseudoHeadersPresent(headers); assertThat(headers.size()).isEqualTo(headersSizeBefore + 1); assertThat(headers.authority()).isEqualTo("foo"); assertThat(headers.get("name2")).isEqualTo("value2"); assertThat(headers.get("name3")).isEqualTo("value3"); assertThat(headers.get("name4")).isEqualTo("value4"); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
protected HtmlRenderable htmlBody() { return sequence( HtmlElement.div(cssClass("dir-container")).content( HtmlElement.span(cssClass("directory")).content( HtmlElement.a(onclick("BuildDetail.tree_navigator(this)")) .content(getFileName()) ) ), HtmlElement.div(cssClass("subdir-container"), style("display:none")) .content(subDirectory) ); }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software 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 testInvalidGroupId(final String groupId, final boolean mustFail) { adminPage(); findElementByLink("Configure Users, Groups and On-Call Roles").click(); findElementByLink("Configure Groups").click(); findElementByLink("Add new group").click(); enterText(By.id("groupName"), groupId); enterText(By.id("groupComment"), "SmokeTestComment"); findElementByXpath("//button[@type='submit' and text()='OK']").click(); if (mustFail) { try { final Alert alert = wait.withTimeout(Duration.of(5, ChronoUnit.SECONDS)).until(ExpectedConditions.alertIsPresent()); alert.dismiss(); } catch (final Exception e) { LOG.debug("Got an exception waiting for a 'invalid group ID' alert.", e); throw e; } } else { wait.until(ExpectedConditions.elementToBeClickable(By.name("finish"))); } }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software 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
safe
public void testWhitespaceInTransferEncoding01() { String requestStr = "GET /some/path HTTP/1.1\r\n" + "Transfer-Encoding : chunked\r\n" + "Content-Length: 1\r\n" + "Host: netty.io\r\n\r\n" + "a"; testInvalidHeaders0(requestStr); }
1
Java
CWE-444
Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')
The product acts as an intermediary HTTP agent (such as a proxy or firewall) in the data flow between two entities such as a client and server, but it does not interpret malformed HTTP requests or responses in ways that are consistent with how the messages will be processed by those entities that are at the ultimate destination.
https://cwe.mitre.org/data/definitions/444.html
safe
public boolean isValidating() { return validating; }
0
Java
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
protected BigDecimal bcdToBigDecimal() { if (usingBytes) { // Converting to a string here is faster than doing BigInteger/BigDecimal arithmetic. BigDecimal result = new BigDecimal(toNumberString()); if (isNegative()) { result = result.negate(); } return result; } else { long tempLong = 0L; for (int shift = (precision - 1); shift >= 0; shift--) { tempLong = tempLong * 10 + getDigitPos(shift); } BigDecimal result = BigDecimal.valueOf(tempLong); try { result = result.scaleByPowerOfTen(scale); } catch (ArithmeticException e) { if (e.getMessage().contains("Underflow")) { result = BigDecimal.ZERO; } else { throw e; } } if (isNegative()) result = result.negate(); return result; } }
1
Java
CWE-190
Integer Overflow or Wraparound
The software 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
safe
private ModelAndView addGroup(HttpServletRequest request, HttpServletResponse response) throws Exception { String groupName = request.getParameter("groupName"); String groupComment = request.getParameter("groupComment"); if (groupComment == null) { groupComment = ""; } if (groupName != null && groupName.matches(".*[&<>\"`']+.*")) { throw new ServletException("Group ID must not contain any HTML markup."); } if (groupComment != null && groupComment.matches(".*[&<>\"`']+.*")) { throw new ServletException("Group comment must not contain any HTML markup."); } boolean hasGroup = false; try { hasGroup = m_groupRepository.groupExists(groupName); } catch (Throwable e) { throw new ServletException("Can't determine if group " + groupName + " already exists in groups.xml.", e); } if (hasGroup) { return new ModelAndView("admin/userGroupView/groups/newGroup", "action", "redo"); } else { WebGroup newGroup = new WebGroup(); newGroup.setName(groupName); newGroup.setComments(groupComment); return editGroup(request, newGroup); } }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software 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
safe
public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isEmpty(value)) { return true; } try { Pattern.compile(value); return true; } catch (Exception ex) { String errorMessage = String.format("URL parameter '%s' is not a valid regexp", value); LOG.warn(errorMessage); context.buildConstraintViolationWithTemplate(errorMessage).addConstraintViolation(); } return false; }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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 isProbablePrime(BigInteger x, int iterations) { /* * Primes class for FIPS 186-4 C.3 primality checking */ return !Primes.hasAnySmallFactors(x) && Primes.isMRProbablePrime(x, param.getRandom(), iterations); }
0
Java
CWE-327
Use of a Broken or Risky Cryptographic Algorithm
The use of a broken or risky cryptographic algorithm is an unnecessary risk that may result in the exposure of sensitive information.
https://cwe.mitre.org/data/definitions/327.html
vulnerable
public void testValidUserIds() { testInvalidUserId("John-Doe",false); testInvalidUserId("Jane/Doe",false); testInvalidUserId("John.Doe",false); testInvalidUserId("Jane#Doe", false); testInvalidUserId("John@Döe.com", false); testInvalidUserId("JohnDoé", false); }
1
Java
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
safe
private ModelAndView renameGroup(HttpServletRequest request, HttpServletResponse response) throws Exception { String oldName = request.getParameter("groupName"); String newName = request.getParameter("newName"); if (StringUtils.hasText(oldName) && StringUtils.hasText(newName)) { m_groupRepository.renameGroup(oldName, newName); } return listGroups(request, response); }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software 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 testFilter() { final Collection<String> includes = new ArrayList<String>() {{ add( "git://**" ); }}; final Collection<String> excludes = new ArrayList<String>() {{ add( "default://**" ); }}; { final Path path = Paths.get( URI.create( "file:///Users/home" ) ); Assert.assertFalse( filter( includes, excludes, path ) ); } { final Path path = Paths.get( URI.create( "git://antpathmatcher" ) ); Assert.assertTrue( filter( includes, excludes, path ) ); } { final Path path = Paths.get( URI.create( "git://master@antpathmatcher/repo/sss" ) ); Assert.assertTrue( filter( includes, excludes, path ) ); } Assert.assertTrue( filter( Collections.<String>emptyList(), Collections.<String>emptyList(), Paths.get( URI.create( "git://master@antpathmatcher/repo/sss" ) ) ) ); Assert.assertTrue( filter( Collections.<String>emptyList(), Collections.<String>emptyList(), Paths.get( URI.create( "git://antpathmatcher" ) ) ) ); }
1
Java
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
private void checkClassName(final List<String> classnameWhitelist, final String className) { if (classnameWhitelist == null) { return; } classnameWhitelist.forEach(pattern -> { if (!Wildcard.equalsOrMatch(className, pattern)) { throw new JsonException("Class can't be loaded as it is not whitelisted: " + className); } }); }
1
Java
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
safe
public InputStream getResourceAsStream(String path) throws IOException { return classLoader.getResourceAsStream(THEME_RESOURCES_RESOURCES + path); }
0
Java
NVD-CWE-noinfo
null
null
null
vulnerable
public void newDocumentWebHomeFromURLTemplateProviderSpecifiedButOldPageType() throws Exception { // new document = xwiki:X.Y.WebHome DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("X", "Y"), "WebHome"); XWikiDocument document = mock(XWikiDocument.class); when(document.getDocumentReference()).thenReturn(documentReference); when(document.isNew()).thenReturn(true); when(document.getLocalReferenceMaxLength()).thenReturn(255); context.setDoc(document); // Specifying a template provider in the URL: templateprovider=XWiki.MyTemplateProvider String templateProviderFullName = "XWiki.MyTemplateProvider"; when(mockRequest.getParameter("templateprovider")).thenReturn(templateProviderFullName); // Mock 1 existing template provider mockExistingTemplateProviders(templateProviderFullName, new DocumentReference("xwiki", Arrays.asList("XWiki"), "MyTemplateProvider"), Collections.EMPTY_LIST, null, "page"); // Run the action String result = action.render(context); // The tests are below this line! // Verify null is returned (this means the response has been returned) assertNull(result); // Note: We are creating the document X.Y as terminal, since the template provider did not specify a "terminal" // property and it used the old "page" type instead. Also using a template, as specified in the template // provider. verify(mockURLFactory).createURL("X", "Y", "edit", "template=XWiki.MyTemplate&parent=Main.WebHome&title=Y", null, "xwiki", context); }
0
Java
CWE-862
Missing Authorization
The software 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 static boolean isAbsolute(String url) { if (url.startsWith("//")) // //www.domain.com/start { return true; } if (url.startsWith("/")) // /somePage.html { return false; } boolean result = false; try { URI uri = new URI(url); result = uri.isAbsolute(); } catch (URISyntaxException e) {} //Ignore return result; }
0
Java
CWE-601
URL Redirection to Untrusted Site ('Open Redirect')
A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.
https://cwe.mitre.org/data/definitions/601.html
vulnerable
public CreateCommentResponse save(CreateCommentRequest createCommentRequest) { CreateCommentResponse createCommentResponse = new CreateCommentResponse(); if (createCommentRequest.getLogId() != null && createCommentRequest.getComment() != null) { if (isAllowComment(Integer.valueOf(createCommentRequest.getLogId()))) { String comment = Jsoup.clean(createCommentRequest.getComment(), Whitelist.basic()); if (comment.length() > 0 && !ParseUtil.isGarbageComment(comment)) { new Comment().set("userHome", createCommentRequest.getUserHome()) .set("userMail", createCommentRequest.getComment()) .set("userIp", createCommentRequest.getIp()) .set("userName", createCommentRequest.getUserName()) .set("logId", createCommentRequest.getLogId()) .set("userComment", comment) .set("user_agent", createCommentRequest.getUserAgent()) .set("reply_id", createCommentRequest.getReplyId()) .set("commTime", new Date()).set("hide", 1).save(); } else { createCommentResponse.setError(1); createCommentResponse.setMessage(""); } } else { createCommentResponse.setError(1); createCommentResponse.setMessage(""); } } else { createCommentResponse.setError(1); createCommentResponse.setMessage(""); } Log log = new Log().findByIdOrAlias(createCommentRequest.getLogId()); if (log != null) { createCommentResponse.setAlias(log.getStr("alias")); } return createCommentResponse; }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software 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 multipleTestingOfSameClass() { assertThat(ConstraintViolations.format(validator.validate(new CorrectExample()))) .isEmpty(); assertThat(ConstraintViolations.format(validator.validate(new CorrectExample()))) .isEmpty(); assertThat(TestLoggerFactory.getAllLoggingEvents()) .isEmpty(); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
public void test_like_startsWith() { Entity from = from(Entity.class); where(from.getCode()).like().startsWith("test"); Query<Entity> select = select(from); assertEquals("select entity_0 from Entity entity_0 where entity_0.code like :code_1", select.getQuery()); assertEquals("test%", select.getParameters().get("code_1")); }
1
Java
NVD-CWE-noinfo
null
null
null
safe
public void violationMessagesAreEscapedByDefault() { assertThat(ConstraintViolations.format(validator.validate(new InjectionExample()))).containsExactly( " $\\A{1+1}", " ${'value'}", " {value}", "${'property'} ${'value'}", "${'property'}[${'key'}] ${'value'}", "${'property'}[1] ${'value'}" ); assertThat(TestLoggerFactory.getAllLoggingEvents()).isEmpty(); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
private String escapeEl(@Nullable String s) { if (s == null || s.isEmpty()) { return s; } final Matcher m = ESCAPE_PATTERN.matcher(s); final StringBuffer sb = new StringBuffer(s.length() + 16); while (m.find()) { m.appendReplacement(sb, "\\\\\\${"); } m.appendTail(sb); return sb.toString(); }
0
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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 FromSkinparamToStyle(String key) { if (key.contains("<<")) { final StringTokenizer st = new StringTokenizer(key, "<>"); this.key = st.nextToken(); this.stereo = st.hasMoreTokens() ? st.nextToken() : null; } else { this.key = key; this.stereo = 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 String getMimeType(ParsedUri pParsedUri) { if (pParsedUri.getParameter(ConfigKey.CALLBACK.getKeyValue()) != null) { return "text/javascript"; } else { String mimeType = pParsedUri.getParameter(ConfigKey.MIME_TYPE.getKeyValue()); if (mimeType != null) { return mimeType; } mimeType = configuration.get(ConfigKey.MIME_TYPE); return mimeType != null ? mimeType : ConfigKey.MIME_TYPE.getDefaultValue(); } }
0
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software 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
private static void assertProhibited(String rawPath) { assertThat(parse(rawPath)) .as("Ensure parse(\"%s\") returns null.", rawPath) .isNull(); }
1
Java
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
safe
private final HColor getLineColor(ISkinParam skinParam, Style style) { if (colors == null || colors.getColor(ColorType.LINE) == null) { if (UseStyle.useBetaStyle() == false) return HColorUtils.COL_038048; return style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()); } return colors.getColor(ColorType.LINE); }
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 addViolation(String propertyName, String key, String message, Map<String, Object> messageParameters) { violationOccurred = true; final String messageTemplate = sanitizeTemplate(message); final HibernateConstraintValidatorContext context = getContextWithMessageParameters(messageParameters); context.buildConstraintViolationWithTemplate(messageTemplate) .addPropertyNode(propertyName) .addBeanNode().inIterable().atKey(key) .addConstraintViolation(); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
private ECFieldElement fe(BigInteger x) { return DP.getCurve().fromBigInteger(x); }
1
Java
CWE-19
Data Processing Errors
Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.
https://cwe.mitre.org/data/definitions/19.html
safe
void headersWithSameNamesAndValuesShouldBeEquivalent() { final HttpHeadersBase headers1 = newEmptyHeaders(); headers1.add("name1", "value1"); headers1.add("name2", "value2"); headers1.add("name2", "value3"); final HttpHeadersBase headers2 = newEmptyHeaders(); headers2.add("name1", "value1"); headers2.add("name2", "value2"); headers2.add("name2", "value3"); assertThat(headers2).isEqualTo(headers1); assertThat(headers1).isEqualTo(headers2); assertThat(headers1).isEqualTo(headers1); assertThat(headers2).isEqualTo(headers2); assertThat(headers2.hashCode()).isEqualTo(headers1.hashCode()); assertThat(headers1.hashCode()).isEqualTo(headers1.hashCode()); assertThat(headers2.hashCode()).isEqualTo(headers2.hashCode()); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
void doubleQuote() { final PathAndQuery res = parse("/\"?\""); assertThat(res).isNotNull(); assertThat(res.path()).isEqualTo("/%22"); assertThat(res.query()).isEqualTo("%22"); }
1
Java
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
safe
private boolean isStale(URL source, File target) { if( source.getProtocol().equals("jar") ) { // unwrap the jar protocol... try { String parts[] = source.getFile().split(Pattern.quote("!")); source = new URL(parts[0]); } catch (MalformedURLException e) { return false; } } File sourceFile=null; if( source.getProtocol().equals("file") ) { sourceFile = new File(source.getFile()); } if( sourceFile!=null && sourceFile.exists() ) { if( sourceFile.lastModified() > target.lastModified() ) { return true; } } return false; }
0
Java
CWE-94
Improper Control of Generation of Code ('Code Injection')
The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
https://cwe.mitre.org/data/definitions/94.html
vulnerable
public BourneShell() { this( false ); }
0
Java
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
private HibernateConstraintValidatorContext getContextWithMessageParameters(Map<String, Object> messageParameters) { final HibernateConstraintValidatorContext context = constraintValidatorContext.unwrap(HibernateConstraintValidatorContext.class); for (Map.Entry<String, Object> messageParameter : messageParameters.entrySet()) { final Object value = messageParameter.getValue(); final String escapedValue = value == null ? null : escapeMessageParameter(value.toString()); context.addMessageParameter(messageParameter.getKey(), escapedValue); } return context; }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe
public void addViolation(String propertyName, String message) { addViolation(propertyName, message, Collections.emptyMap()); }
1
Java
CWE-74
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
The software 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
safe