Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Security Report: 24 high severity findings, 41 total findings #14

Open
1 task
mend-for-github-com bot opened this issue Nov 19, 2023 · 0 comments
Open
1 task
Labels
Mend: code security findings Code security findings detected by Mend

Comments

@mend-for-github-com
Copy link
Contributor

mend-for-github-com bot commented Nov 19, 2023

Code Security Report

Scan Metadata

Latest Scan: 2023-11-20 07:14pm
Total Findings: 41 | New Findings: 0 | Resolved Findings: 0
Tested Project Files: 135
Detected Programming Languages: 2 (JavaScript / Node.js, Java*)

  • Check this box to manually trigger a scan

Most Relevant Findings

The below list presents the 10 most relevant findings that need your attention. To view information on the remaining findings, navigate to the Mend Application.

SeverityVulnerability TypeCWEFileData FlowsDate
HighCommand Injection

CWE-78

index.jsp:65

22023-11-20 03:20pm
Vulnerable Code

shell = "bash";
shellarg = "-c";
command = "cat '" + path + "/" + content +"'";
}
Process proc = Runtime.getRuntime().exec(new String[] {shell, shellarg, command});

2 Data Flow/s detected
View Data Flow 1

content = request.getParameter("content");

command = "cat '" + path + "/" + content +"'";

Process proc = Runtime.getRuntime().exec(new String[] {shell, shellarg, command});

Process proc = Runtime.getRuntime().exec(new String[] {shell, shellarg, command});

View Data Flow 2

content = request.getParameter("content");

command = "cat '" + path + "/" + content +"'";

Process proc = Runtime.getRuntime().exec(new String[] {shell, shellarg, command});

Process proc = Runtime.getRuntime().exec(new String[] {shell, shellarg, command});

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Command Injection Training

● Videos

   ▪ Secure Code Warrior Command Injection Video

● Further Reading

   ▪ OWASP testing for Command Injection

   ▪ OWASP Command Injection

 
HighSQL Injection

CWE-89

DBUtil.java:494

22023-11-20 03:20pm
Vulnerable Code

public static String addUser(String username, String password, String firstname, String lastname) {
try {
Connection connection = getConnection();
Statement statement = connection.createStatement();
statement.execute("INSERT INTO PEOPLE (USER_ID,PASSWORD,FIRST_NAME,LAST_NAME,ROLE) VALUES ('"+username+"','"+password+"', '"+firstname+"', '"+lastname+"','user')");

2 Data Flow/s detected
View Data Flow 1

String username = request.getParameter("username");

String error = DBUtil.addUser(username, password1, firstname, lastname);

public static String addUser(String username, String password, String firstname, String lastname) {

statement.execute("INSERT INTO PEOPLE (USER_ID,PASSWORD,FIRST_NAME,LAST_NAME,ROLE) VALUES ('"+username+"','"+password+"', '"+firstname+"', '"+lastname+"','user')");

statement.execute("INSERT INTO PEOPLE (USER_ID,PASSWORD,FIRST_NAME,LAST_NAME,ROLE) VALUES ('"+username+"','"+password+"', '"+firstname+"', '"+lastname+"','user')");

View Data Flow 2

public Response addUser(String bodyJSON, @Context HttpServletRequest request) throws IOException{

bodyJson =new JSONObject(bodyJSON);

bodyJson =new JSONObject(bodyJSON);

lastname = bodyJson.get("lastname").toString();

lastname = bodyJson.get("lastname").toString();

lastname = bodyJson.get("lastname").toString();

lastname = bodyJson.get("lastname").toString();

error = DBUtil.addUser(username, password1, firstname, lastname);

public static String addUser(String username, String password, String firstname, String lastname) {

statement.execute("INSERT INTO PEOPLE (USER_ID,PASSWORD,FIRST_NAME,LAST_NAME,ROLE) VALUES ('"+username+"','"+password+"', '"+firstname+"', '"+lastname+"','user')");

statement.execute("INSERT INTO PEOPLE (USER_ID,PASSWORD,FIRST_NAME,LAST_NAME,ROLE) VALUES ('"+username+"','"+password+"', '"+firstname+"', '"+lastname+"','user')");

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

 
HighSQL Injection

CWE-89

DBUtil.java:471

12023-11-20 03:20pm
Vulnerable Code

public static String addAccount(String username, String acctType) {
try {
Connection connection = getConnection();
Statement statement = connection.createStatement();
statement.execute("INSERT INTO ACCOUNTS (USERID,ACCOUNT_NAME,BALANCE) VALUES ('"+username+"','"+acctType+"', 0)");

1 Data Flow/s detected

String username = request.getParameter("username");

String error = DBUtil.addAccount(username, acctType);

public static String addAccount(String username, String acctType) {

statement.execute("INSERT INTO ACCOUNTS (USERID,ACCOUNT_NAME,BALANCE) VALUES ('"+username+"','"+acctType+"', 0)");

statement.execute("INSERT INTO ACCOUNTS (USERID,ACCOUNT_NAME,BALANCE) VALUES ('"+username+"','"+acctType+"', 0)");

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

 
HighCode Injection

CWE-94

serverStatusCheck.html:41

12023-11-20 03:20pm
Vulnerable Code

}
function StateChangeForJSON()
{
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
var jsonObj = eval('('+ xmlHttp.responseText + ')');

1 Data Flow/s detected

var jsonObj = eval('('+ xmlHttp.responseText + ')');

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Code Injection Training

● Videos

   ▪ Secure Code Warrior Code Injection Video

● Further Reading

   ▪ OWASP Command Injection

 
HighSQL Injection

CWE-89

DBUtil.java:219

32023-11-19 11:34pm
Vulnerable Code

return false;
Connection connection = getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet =statement.executeQuery("SELECT COUNT(*)FROM PEOPLE WHERE USER_ID = '"+ user +"' AND PASSWORD='" + password + "'"); /* BAD - user input should always be sanitized */

3 Data Flow/s detected
View Data Flow 1

String passwd = request.getParameter("passwd");

if (DBUtil.isValidUser(user.getUsername(), passwd.trim())) {

if (DBUtil.isValidUser(user.getUsername(), passwd.trim())) {

if (DBUtil.isValidUser(user.getUsername(), passwd.trim())) {

public static boolean isValidUser(String user, String password) throws SQLException{

ResultSet resultSet =statement.executeQuery("SELECT COUNT(*)FROM PEOPLE WHERE USER_ID = '"+ user +"' AND PASSWORD='" + password + "'"); /* BAD - user input should always be sanitized */

ResultSet resultSet =statement.executeQuery("SELECT COUNT(*)FROM PEOPLE WHERE USER_ID = '"+ user +"' AND PASSWORD='" + password + "'"); /* BAD - user input should always be sanitized */

View Data Flow 2

String password = request.getParameter("passw");

password = password.trim().toLowerCase(); //in real life the password usually is case sensitive and this cast would not be done

password = password.trim().toLowerCase(); //in real life the password usually is case sensitive and this cast would not be done

password = password.trim().toLowerCase(); //in real life the password usually is case sensitive and this cast would not be done

password = password.trim().toLowerCase(); //in real life the password usually is case sensitive and this cast would not be done

if (!DBUtil.isValidUser(username, password)){

public static boolean isValidUser(String user, String password) throws SQLException{

ResultSet resultSet =statement.executeQuery("SELECT COUNT(*)FROM PEOPLE WHERE USER_ID = '"+ user +"' AND PASSWORD='" + password + "'"); /* BAD - user input should always be sanitized */

ResultSet resultSet =statement.executeQuery("SELECT COUNT(*)FROM PEOPLE WHERE USER_ID = '"+ user +"' AND PASSWORD='" + password + "'"); /* BAD - user input should always be sanitized */

View Data Flow 3

public Response login(String bodyJSON, @Context HttpServletRequest request) throws JSONException {

password = myJson.get("password").toString().toLowerCase();

password = myJson.get("password").toString().toLowerCase();

password = myJson.get("password").toString().toLowerCase();

password = myJson.get("password").toString().toLowerCase();

password = myJson.get("password").toString().toLowerCase();

password = myJson.get("password").toString().toLowerCase();

if (!DBUtil.isValidUser(username, password)) {

public static boolean isValidUser(String user, String password) throws SQLException{

ResultSet resultSet =statement.executeQuery("SELECT COUNT(*)FROM PEOPLE WHERE USER_ID = '"+ user +"' AND PASSWORD='" + password + "'"); /* BAD - user input should always be sanitized */

ResultSet resultSet =statement.executeQuery("SELECT COUNT(*)FROM PEOPLE WHERE USER_ID = '"+ user +"' AND PASSWORD='" + password + "'"); /* BAD - user input should always be sanitized */

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

 
HighSQL Injection

CWE-89

DBUtil.java:506

22023-11-19 11:34pm
Vulnerable Code

public static String changePassword(String username, String password) {
try {
Connection connection = getConnection();
Statement statement = connection.createStatement();
statement.execute("UPDATE PEOPLE SET PASSWORD = '"+ password +"' WHERE USER_ID = '"+username+"'");

2 Data Flow/s detected
View Data Flow 1

String password1 = request.getParameter("password1");

String error = DBUtil.changePassword(username, password1);

public static String changePassword(String username, String password) {

statement.execute("UPDATE PEOPLE SET PASSWORD = '"+ password +"' WHERE USER_ID = '"+username+"'");

statement.execute("UPDATE PEOPLE SET PASSWORD = '"+ password +"' WHERE USER_ID = '"+username+"'");

View Data Flow 2

public Response changePassword(String bodyJSON, @Context HttpServletRequest request) throws IOException{

bodyJson =new JSONObject(bodyJSON);

bodyJson =new JSONObject(bodyJSON);

username = bodyJson.get("username").toString();

username = bodyJson.get("username").toString();

username = bodyJson.get("username").toString();

username = bodyJson.get("username").toString();

error = DBUtil.changePassword(username, password1);

public static String changePassword(String username, String password) {

statement.execute("UPDATE PEOPLE SET PASSWORD = '"+ password +"' WHERE USER_ID = '"+username+"'");

statement.execute("UPDATE PEOPLE SET PASSWORD = '"+ password +"' WHERE USER_ID = '"+username+"'");

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

 
HighSQL Injection

CWE-89

DBUtil.java:242

22023-11-19 11:34pm
Vulnerable Code

if (username == null || username.trim().length() == 0)
return null;
Connection connection = getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet =statement.executeQuery("SELECT FIRST_NAME,LAST_NAME,ROLE FROM PEOPLE WHERE USER_ID = '"+ username +"' "); /* BAD - user input should always be sanitized */

2 Data Flow/s detected
View Data Flow 1

Cookie accountCookie = ServletUtil.establishSession(username,session);

public static Cookie establishSession(String username, HttpSession session){

User user = DBUtil.getUserInfo(username);

public static User getUserInfo(String username) throws SQLException{

ResultSet resultSet =statement.executeQuery("SELECT FIRST_NAME,LAST_NAME,ROLE FROM PEOPLE WHERE USER_ID = '"+ username +"' "); /* BAD - user input should always be sanitized */

ResultSet resultSet =statement.executeQuery("SELECT FIRST_NAME,LAST_NAME,ROLE FROM PEOPLE WHERE USER_ID = '"+ username +"' "); /* BAD - user input should always be sanitized */

View Data Flow 2

String accessToken = request.getHeader("Authorization").replaceAll("Bearer ", "");

String accessToken = request.getHeader("Authorization").replaceAll("Bearer ", "");

String accessToken = request.getHeader("Authorization").replaceAll("Bearer ", "");

String decodedToken = new String(Base64.decodeBase64(accessToken));

String decodedToken = new String(Base64.decodeBase64(accessToken));

String decodedToken = new String(Base64.decodeBase64(accessToken));

String decodedToken = new String(Base64.decodeBase64(accessToken));

StringTokenizer tokenizer = new StringTokenizer(decodedToken,":");

StringTokenizer tokenizer = new StringTokenizer(decodedToken,":");

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

public static User getUserInfo(String username) throws SQLException{

ResultSet resultSet =statement.executeQuery("SELECT FIRST_NAME,LAST_NAME,ROLE FROM PEOPLE WHERE USER_ID = '"+ username +"' "); /* BAD - user input should always be sanitized */

ResultSet resultSet =statement.executeQuery("SELECT FIRST_NAME,LAST_NAME,ROLE FROM PEOPLE WHERE USER_ID = '"+ username +"' "); /* BAD - user input should always be sanitized */

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

 
HighSQL Injection

CWE-89

DBUtil.java:519

12023-11-19 11:34pm
Vulnerable Code

public static long storeFeedback(String name, String email, String subject, String comments) {
try{
Connection connection = getConnection();
Statement statement = connection.createStatement();
statement.execute("INSERT INTO FEEDBACK (NAME,EMAIL,SUBJECT,COMMENTS) VALUES ('"+name+"', '"+email+"', '"+subject+"', '"+comments+"')", Statement.RETURN_GENERATED_KEYS);

1 Data Flow/s detected

String name = request.getParameter("name");

String feedbackId = OperationsUtil.sendFeedback(name, email, subject, comments);

public static String sendFeedback(String name, String email,

long id = DBUtil.storeFeedback(name, email, subject, comments);

public static long storeFeedback(String name, String email, String subject, String comments) {

statement.execute("INSERT INTO FEEDBACK (NAME,EMAIL,SUBJECT,COMMENTS) VALUES ('"+name+"', '"+email+"', '"+subject+"', '"+comments+"')", Statement.RETURN_GENERATED_KEYS);

statement.execute("INSERT INTO FEEDBACK (NAME,EMAIL,SUBJECT,COMMENTS) VALUES ('"+name+"', '"+email+"', '"+subject+"', '"+comments+"')", Statement.RETURN_GENERATED_KEYS);

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

 
HighSQL Injection

CWE-89

DBUtil.java:403

12023-11-20 03:20pm
Vulnerable Code

String query = "SELECT * FROM TRANSACTIONS WHERE (" + acctIds.toString() + ") " + ((dateString==null)?"": "AND (" + dateString + ") ") + "ORDER BY DATE DESC" ;
ResultSet resultSet = null;
try {
resultSet = statement.executeQuery(query);

1 Data Flow/s detected

String endString = request.getParameter("endTime");

transactions = user.getUserTransactions(startString, endString, user.getAccounts());

public Transaction[] getUserTransactions(String startDate, String endDate, Account[] accounts) throws SQLException {

transactions = DBUtil.getTransactions(startDate, endDate, accounts, -1);

public static Transaction[] getTransactions(String startDate, String endDate, Account[] accounts, int rowCount) throws SQLException {

dateString = "DATE < '" + endDate + " 23:59:59'";

String query = "SELECT * FROM TRANSACTIONS WHERE (" + acctIds.toString() + ") " + ((dateString==null)?"": "AND (" + dateString + ") ") + "ORDER BY DATE DESC" ;

String query = "SELECT * FROM TRANSACTIONS WHERE (" + acctIds.toString() + ") " + ((dateString==null)?"": "AND (" + dateString + ") ") + "ORDER BY DATE DESC" ;

resultSet = statement.executeQuery(query);

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

 
HighSQL Injection

CWE-89

DBUtil.java:276

22023-11-19 11:34pm
Vulnerable Code

if (username == null || username.trim().length() == 0)
return null;
Connection connection = getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet =statement.executeQuery("SELECT ACCOUNT_ID, ACCOUNT_NAME, BALANCE FROM ACCOUNTS WHERE USERID = '"+ username +"' "); /* BAD - user input should always be sanitized */

2 Data Flow/s detected
View Data Flow 1

Cookie accountCookie = ServletUtil.establishSession(username,session);

public static Cookie establishSession(String username, HttpSession session){

User user = DBUtil.getUserInfo(username);

public static User getUserInfo(String username) throws SQLException{

User user = new User(username, firstName, lastName);

public User(String username, String firstName, String lastName) {

User user = new User(username, firstName, lastName);

User user = DBUtil.getUserInfo(username);

Account[] accounts = user.getAccounts();

return DBUtil.getAccounts(username);

public static Account[] getAccounts(String username) throws SQLException{

ResultSet resultSet =statement.executeQuery("SELECT ACCOUNT_ID, ACCOUNT_NAME, BALANCE FROM ACCOUNTS WHERE USERID = '"+ username +"' "); /* BAD - user input should always be sanitized */

ResultSet resultSet =statement.executeQuery("SELECT ACCOUNT_ID, ACCOUNT_NAME, BALANCE FROM ACCOUNTS WHERE USERID = '"+ username +"' "); /* BAD - user input should always be sanitized */

View Data Flow 2

String accessToken = request.getHeader("Authorization").replaceAll("Bearer ", "");

String accessToken = request.getHeader("Authorization").replaceAll("Bearer ", "");

String accessToken = request.getHeader("Authorization").replaceAll("Bearer ", "");

String decodedToken = new String(Base64.decodeBase64(accessToken));

String decodedToken = new String(Base64.decodeBase64(accessToken));

String decodedToken = new String(Base64.decodeBase64(accessToken));

String decodedToken = new String(Base64.decodeBase64(accessToken));

StringTokenizer tokenizer = new StringTokenizer(decodedToken,":");

StringTokenizer tokenizer = new StringTokenizer(decodedToken,":");

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

String username = new String(Base64.decodeBase64(tokenizer.nextToken()));

public static User getUserInfo(String username) throws SQLException{

User user = new User(username, firstName, lastName);

public User(String username, String firstName, String lastName) {

User user = new User(username, firstName, lastName);

Account[] account = (OperationsUtil.getUser(request)).getAccounts();

Account[] account = (OperationsUtil.getUser(request)).getAccounts();

return DBUtil.getAccounts(username);

public static Account[] getAccounts(String username) throws SQLException{

ResultSet resultSet =statement.executeQuery("SELECT ACCOUNT_ID, ACCOUNT_NAME, BALANCE FROM ACCOUNTS WHERE USERID = '"+ username +"' "); /* BAD - user input should always be sanitized */

ResultSet resultSet =statement.executeQuery("SELECT ACCOUNT_ID, ACCOUNT_NAME, BALANCE FROM ACCOUNTS WHERE USERID = '"+ username +"' "); /* BAD - user input should always be sanitized */

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior SQL Injection Training

● Videos

   ▪ Secure Code Warrior SQL Injection Video

● Further Reading

   ▪ OWASP SQL Injection Prevention Cheat Sheet

   ▪ OWASP SQL Injection

   ▪ OWASP Query Parameterization Cheat Sheet

Findings Overview

Severity Vulnerability Type CWE Language Count
High Cross-Site Scripting CWE-79 Java* 11
High Command Injection CWE-78 Java* 1
High SQL Injection CWE-89 Java* 8
High DOM Based Cross-Site Scripting CWE-79 JavaScript / Node.js 3
High Code Injection CWE-94 JavaScript / Node.js 1
Medium Trust Boundary Violation CWE-501 Java* 2
Medium Error Messages Information Exposure CWE-209 Java* 10
Medium Hardcoded Password/Credentials CWE-798 JavaScript / Node.js 1
Low Unvalidated/Open Redirect CWE-601 JavaScript / Node.js 4
@mend-for-github-com mend-for-github-com bot added the Mend: code security findings Code security findings detected by Mend label Nov 19, 2023
@mend-for-github-com mend-for-github-com bot changed the title Code Security Report: 24 high severity findings, 41 total findings Code Security Report: 20 high severity findings, 32 total findings Nov 19, 2023
@mend-for-github-com mend-for-github-com bot changed the title Code Security Report: 20 high severity findings, 32 total findings Code Security Report: 24 high severity findings, 41 total findings Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mend: code security findings Code security findings detected by Mend
Projects
None yet
Development

No branches or pull requests

0 participants