JAVA.SV.LLM.MODEL.DESERIAL
LLM 出力の安全でない逆シリアル化
JAVA.SV.LLM.MODEL.DESERIAL チェッカーは、LLM 出力の安全でない逆シリアル化を特定します。
脆弱コード例
コピー
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.util.JsonHelper;
public class Example {
public Object handle(ChatClient client, JsonHelper json) {
String out = client.prompt().user("Return the config as JSON").call().content(); // untrusted LLM output
return json.fromJson(out, Object.class); // deserialized into an object with no validation
}
}
修正コード例
コピー
import org.springframework.ai.util.JsonHelper;
public class Example {
public Object handle(JsonHelper json) {
String out = "{\"table\":\"users\"}"; // trusted/validated input, not raw model output
return json.fromJson(out, Object.class);
}
}
セキュリティトレーニング
Secure Code Warrior が提供しているアプリケーションセキュリティトレーニング教材。