mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Migrate Java code to separate QL repo.
This commit is contained in:
19
java/ql/src/Security/CWE/CWE-421/SocketAuthRace.java
Normal file
19
java/ql/src/Security/CWE/CWE-421/SocketAuthRace.java
Normal file
@@ -0,0 +1,19 @@
|
||||
public void doConnect(int desiredPort, String username) {
|
||||
ServerSocket listenSocket = new ServerSocket(desiredPort);
|
||||
|
||||
if (isAuthenticated(username)) {
|
||||
Socket connection1 = listenSocket.accept();
|
||||
// BAD: no authentication over the socket connection
|
||||
connection1.getOutputStream().write(secretData);
|
||||
}
|
||||
}
|
||||
|
||||
public void doConnect(int desiredPort, String username) {
|
||||
ServerSocket listenSocket = new ServerSocket(desiredPort);
|
||||
|
||||
Socket connection2 = listenSocket.accept();
|
||||
// GOOD: authentication happens over the socket
|
||||
if (doAuthenticate(connection2, username)) {
|
||||
connection2.getOutputStream().write(secretData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user