Skip to content

Commit 72e8c23

Browse files
Merge pull request #207 from AikidoSec/null-byte
Upgrade to latest Zen internals version
2 parents fae8f16 + adf084c commit 72e8c23

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cov: check_binaries
3232

3333
# Binaries :
3434

35-
BASE_URL = https://github.com/AikidoSec/zen-internals/releases/download/v0.1.39
35+
BASE_URL = https://github.com/AikidoSec/zen-internals/releases/download/v0.1.43
3636
FILES = \
3737
libzen_internals_aarch64-apple-darwin.dylib \
3838
libzen_internals_aarch64-apple-darwin.dylib.sha256sum \

agent_api/src/main/java/dev/aikido/agent_api/vulnerabilities/sql_injection/RustSQLInterface.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,37 @@
22

33
import jnr.ffi.LibraryLoader;
44
import jnr.ffi.LibraryOption;
5+
import jnr.ffi.annotations.Encoding;
56
import dev.aikido.agent_api.helpers.logging.LogManager;
67
import dev.aikido.agent_api.helpers.logging.Logger;
78

89
import java.nio.file.Files;
910
import java.nio.file.Path;
1011
import java.util.HashMap;
1112
import java.util.Map;
13+
import java.nio.charset.StandardCharsets;
1214

1315
import static dev.aikido.agent_api.vulnerabilities.sql_injection.GetBinaryPath.getPathForBinary;
1416

1517
public final class RustSQLInterface {
1618
private RustSQLInterface() {}
1719

1820
private static final Logger logger = LogManager.getLogger(RustSQLInterface.class);
21+
22+
@Encoding("UTF-8")
1923
public interface SqlLib {
20-
int detect_sql_injection(String query, String userinput, int dialect);
24+
int detect_sql_injection(String query, long queryLen, String userinput, long userinputLen, int dialect);
2125
}
26+
2227
public static boolean detectSqlInjection(String query, String userInput, Dialect dialect) {
2328
int dialectInteger = dialect.getDialectInteger();
2429
try {
2530
SqlLib lib = loadLibrary();
2631
if (lib != null) {
27-
return lib.detect_sql_injection(query, userInput, dialectInteger) != 0;
32+
long queryLen = query != null ? query.getBytes(StandardCharsets.UTF_8).length : 0;
33+
long userInputLen = userInput != null ? userInput.getBytes(StandardCharsets.UTF_8).length : 0;
34+
int result = lib.detect_sql_injection(query, queryLen, userInput, userInputLen, dialectInteger);
35+
return result == 1;
2836
}
2937
} catch (Throwable e) {
3038
logger.trace(e);

0 commit comments

Comments
 (0)