Zum Hauptinhalt springen
LIVE
CVSS 7.3CVE-2026-138162 | Gammu before 1.45.2 contains a stack-based buffer overflow vulnerability in ALCATEL_EncodeString() that allows attackers to overwrite stack memory via oversized encoded phonebook text. Attackers can supply a crafted backup restored with gammu restore or addnew to an attached Alcatel phone, using GSM extension characters to crash Gammu or potentially execute code.CVSS 8.5CVE-2026-138163 | Gammu before 1.45.2 contains a heap-based buffer overflow in ReadWAPSettingsEntry() that allows attackers to corrupt heap memory via crafted backup files with excess WAP or MMS settings entries. Attackers can supply a backup with more than four TitleNN keys in a [WAPSettings] or [MMSSettings] section, loaded via convertbackup, restore, or GSM_ReadBackupFile, causing crashes or potential code execution.CVSS 4.8CVE-2026-138164 | Gammu before 1.45.2 contains a stack-based buffer overflow vulnerability in SaveBackupText() in backtext.c that allows attackers to corrupt stack memory by supplying long text fields. Attackers can craft a backup with long calendar or note fields that, when converted with gammu convertbackup, writes hex digits past the 10,000-byte stack buffer.CVSS 9.3CVE-2026-138154 | POSTAL 2 before build 26810491 contains a sandbox escape vulnerability that allows malicious Steam Workshop mods to execute code by calling ConsoleCommand with a start file URI. Attackers can ship a batch file in a mod at the predictable workshop install path and launch it via ShellExecuteW, executing commands as the player on Windows.CVSS 8.5CVE-2026-138117 | HyperSpy from 1.2.0 before 2.6.0 contains a code execution vulnerability that allows attackers to run Python code by embedding malicious expression strings evaluated with sympy.sympify(). Attackers can craft .hspy or .zspy files with malicious axis, Expression component, or twin function expressions that execute when victims call hs.load() or restore models.CVSS 8.5CVE-2026-138118 | HyperSpy from 1.4.0 before 2.6.0 contains an insecure deserialization vulnerability that allows attackers to execute arbitrary Python code by supplying crafted stored-model data in .hspy or .zspy files. Attackers can embed a malicious pickle payload in a component's _class_dump or a 'fn'-flagged _whitelist entry, which cloudpickle.loads() (dill in 1.x) runs when the victim restores the model.CVSS 8.7CVE-2026-138119 | Kestra before 1.3.36 contains a reflected cross-site scripting vulnerability that allows unauthenticated attackers to execute JavaScript by injecting HTML into the executions page sort parameter. Attackers can lure logged-in users to a crafted link whose invalid sort value is rendered unsanitized in an error toast, stealing the non-HttpOnly BASIC_AUTH credential cookie to take over the instance.CVSS 6.9CVE-2026-138120 | Kestra 1.3.24 before 2.0.0 contains a timing side-channel vulnerability in BasicAuthService.isAuthenticated() that allows unauthenticated attackers to enumerate the administrator username. Attackers can send Basic-auth requests with candidate usernames to protected API endpoints and detect slower bcrypt checks to identify the valid account for password guessing.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

LLM Frameworks vs. the Raw SDK in Java

Introduction Every LLM ecosystem now has at least one framework promising to make agents easier to build, and every framework post either oversells the…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Cloud & Tech-Stack · 11 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung




Introduction



Every LLM ecosystem now has at least one framework promising to make agents easier to build, and every framework post either oversells the abstraction or dismisses it outright. Neither is useful. The only honest way to evaluate a framework is to build the same thing twice — once on the vendor's raw SDK, once on the framework — and compare what each version actually cost you and actually gave you back.



This post builds the small tool-using agent from Building Agentic Workflows in Java three ways: on the raw Anthropic Java SDK, on LangChain4j, and on Spring AI. We'll also touch the RAG pipeline from RAG From Scratch in Java — retrieval is exactly the kind of component a framework's tool abstraction is built to wrap. The goal isn't to crown a winner; it's to give you a way to make this decision for your own project instead of inheriting someone else's blog-post conclusion.









The Agent We're Building Three Times



To keep the comparison fair, every version gets the identical agent: one system prompt, two tools, one user turn, running until the model stops asking for tools.





  • getWeather(String location) — the same illustrative weather lookup from the agentic-workflows post, so the tool-calling shape lines up exactly with what you've already seen built by hand.


  • calculate(String operation, double a, double b) — a second tool with a constrained, whitelisted operation argument (add / subtract / multiply / divide) rather than a free-text expression. This is deliberate: it's the "never build a shell/SQL string from model input" lesson from the agentic-workflows post, made concrete as a schema choice instead of a runtime check.



Every framework below turns the same two methods into tool schemas — they differ in how a Java method becomes something the model can call, not in what the agent does.









Path A: The Raw Anthropic Java SDK



This is the manual loop from Building Agentic Workflows in Java, condensed to this agent's two tools. Every tool call passes through code you wrote and can inspect:




import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.core.JsonValue;
import com.anthropic.models.messages.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

AnthropicClient client = AnthropicOkHttpClient.fromEnv(); // reads ANTHROPIC_API_KEY

Tool getWeatherTool = Tool.builder().name("get_weather").description("Get current weather for a location")
.inputSchema(Tool.InputSchema.builder()
.properties(Tool.InputSchema.Properties.builder()
.putAdditionalProperty("location", JsonValue.from(Map.of("type", "string"))).build())
.required(List.of("location")).build())
.build();

Tool calculateTool = Tool.builder().name("calculate").description("Perform basic arithmetic on two numbers")
.inputSchema(Tool.InputSchema.builder()
.properties(Tool.InputSchema.Properties.builder()
.putAdditionalProperty("operation", JsonValue.from(
Map.of("type", "string", "enum", List.of("add", "subtract", "multiply", "divide"))))
.putAdditionalProperty("a", JsonValue.from(Map.of("type", "number")))
.putAdditionalProperty("b", JsonValue.from(Map.of("type", "number"))).build())
.required(List.of("operation", "a", "b")).build())
.build();

List<MessageParam> messages = new ArrayList<>();
messages.add(MessageParam.builder().role(MessageParam.Role.USER)
.content("What's the weather in Austin, and what's 12 divided by 4?").build());

int iterations = 0;
final int maxIterations = 10;
Message response;
while (true) {
if (++iterations > maxIterations) throw new IllegalStateException("Agent exceeded iteration cap — stopping");

response = client.messages().create(MessageCreateParams.builder()
.model(Model.CLAUDE_OPUS_4_8).maxTokens(16000L)
.thinking(ThinkingConfigAdaptive.builder().build())
.addTool(getWeatherTool).addTool(calculateTool)
.messages(messages)
.build());

if (response.stopReason().isPresent() && response.stopReason().get().toString().equals("end_turn")) break;

messages.add(MessageParam.builder().role(MessageParam.Role.ASSISTANT)
.contentOfBlockParams(toBlockParams(response.content())).build());

List<ContentBlockParam> toolResults = new ArrayList<>();
for (ContentBlock block : response.content()) {
block.toolUse().ifPresent(toolUse -> {
// Validate/whitelist BEFORE executing — toolUse.input() is model-provided, untrusted data
String result = executeValidatedTool(toolUse.name(), toolUse.input());
toolResults.add(ContentBlockParam.ofToolResult(ToolResultBlockParam.builder()
.toolUseId(toolUse.id()).content(result).build()));
});
}
messages.add(MessageParam.builder().role(MessageParam.Role.USER)
.contentOfBlockParams(toolResults).build());
}






All of it visible: the hand-written Tool schemas, the loop, the iteration cap, and one explicit choke point (executeValidatedTool) where every tool call is checked before it runs.









Path B: LangChain4j — @Tool Methods + AiServices



LangChain4j replaces hand-written Tool schemas with reflection over annotated methods, and replaces the while loop with a proxy interface. Add the core library and the Anthropic model module:




<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-anthropic</artifactId>
<version>1.17.1</version>
</dependency>






Define both tools as plain methods, annotated with @Tool/@P:




import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.P;

class AgentTools {
@Tool("Get current weather for a location")
String getWeather(@P("City and state, e.g. San Francisco, CA") String location) {
return "Sunny, 72F in " + location;
}

@Tool("Perform basic arithmetic on two numbers")
double calculate(@P("One of: add, subtract, multiply, divide") String operation,
@P("First operand") double a, @P("Second operand") double b) {
if (operation.equals("divide") && b == 0) throw new IllegalArgumentException("Division by zero");
return switch (operation) {
case "add" -> a + b;
case "subtract" -> a - b;
case "multiply" -> a * b;
case "divide" -> a / b;
default -> throw new IllegalArgumentException("Unknown operation: " + operation);
};
}
}






Wire an AnthropicChatModel and a proxy interface through AiServices — this is where create_agent's Python equivalent shows up on the Java side:




import dev.langchain4j.model.anthropic.AnthropicChatModel;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.service.AiServices;

ChatModel model = AnthropicChatModel.builder()
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.modelName("claude-opus-4-8")
.thinkingType("adaptive")
.maxTokens(16000)
.build();

interface Assistant {
String chat(String userMessage);
}

Assistant assistant = AiServices.builder(Assistant.class)
.chatModel(model)
.tools(new AgentTools())
.build();

String answer = assistant.chat("What's the weather in Austin, and what's 12 divided by 4?");
System.out.println(answer);






AiServices generates the tool JSON schema from each @Tool method's signature and @P descriptions, runs the request/tool-execute/reprocess loop internally, and returns the final answer as a plain String — the entire loop from Path A collapses into one .chat(...) call, at the cost of the trade-off the agentic-workflows post named for the SDK's own tool runner: validation now lives inside getWeather/calculate, not at a single choke point you control. (thinkingType("adaptive") omits thinkingBudgetTokens deliberately — a token budget has no meaning for adaptive mode, the same "no budget_tokens on Opus 4.8" rule as the raw SDK.)









Path C: Spring AI — @Tool Methods + ChatClient



Spring AI takes the same annotation-driven approach through its own @Tool/@ToolParam types and a ChatClient builder, with ToolCallingAdvisor managing the loop instead of AiServices:




<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-anthropic</artifactId>
</dependency>






The tool class is the same shape as LangChain4j's, with Spring AI's own annotations in place of @Tool/@P — calculate's whitelisted-operation body is identical to the LangChain4j version above:




import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

class AgentTools {
@Tool(description = "Get current weather for a location")
String getWeather(@ToolParam(description = "City and state, e.g. San Francisco, CA") String location) {
return "Sunny, 72F in " + location;
}

@Tool(description = "Perform basic arithmetic on two numbers")
double calculate(@ToolParam(description = "add/subtract/multiply/divide") String operation,
@ToolParam double a, @ToolParam double b) {
// same whitelisted-operation body as the LangChain4j calculate() above
return dispatchCalculate(operation, a, b);
}
}









import org.springframework.ai.anthropic.AnthropicChatModel;
import org.springframework.ai.anthropic.AnthropicChatOptions;
import org.springframework.ai.chat.client.ChatClient;

var chatModel = AnthropicChatModel.builder()
.options(AnthropicChatOptions.builder()
.model("claude-opus-4-8")
.thinkingAdaptive()
.maxTokens(16000)
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build())
.build();

String answer = ChatClient.create(chatModel)
.prompt("What's the weather in Austin, and what's 12 divided by 4?")
.tools(new AgentTools())
.call()
.content();






ChatClient auto-registers ToolCallingAdvisor whenever .tools(...) is present, so the loop is handled the same way AiServices handles it in LangChain4j. In a Spring Boot app, AnthropicChatModel and ChatClient.Builder are typically autoconfigured beans (via the starter + spring.ai.anthropic.api-key) rather than built by hand as shown here.









Where the Framework Actually Earns Its Weight



For this agent — two tools, one provider, one turn — both frameworks mostly buy convenience over the SDK's own manual loop. Their case gets much stronger once your requirements grow past a single call:












































Need Raw SDK LangChain4j Spring AI
Java method → tool schema Hand-write Tool.InputSchema

@Tool/@P reflection

@Tool/@ToolParam reflection
Swap chat model/provider Rewrite the request builder Swap ChatModel behind AiServices
Swap the bean behind ChatClient
Spring-managed config/DI You own the wiring Usable, not Spring-native First-class: properties + autoconfigured beans
RAG retrieval as a component Hand-roll (RAG-from-scratch post) Built-in EmbeddingStore abstractions Built-in VectorStore/Advisor abstractions
Typed step hand-off StructuredMessageCreateParams<T> Structured Outputs on return type
.entity(Class) on ChatClient


The pattern across every row: the framework's value shows up when there's a policy or integration surface (Spring wiring, a swappable model, a retrieval abstraction) that should apply uniformly across a larger application, not when there's one call site. A single small agent has, definitionally, one call site.









Where It's Ceremony



For the agent this post builds, either framework costs an extra module dependency, an abstraction layer over the documented Anthropic request/response shape, and a release cadence to track alongside the SDK's — both frameworks' tool/model APIs have evolved across releases, exactly the risk this post's verification bar exists to catch (every snippet above was checked against current docs and source, not memory). That's not a reason to avoid frameworks; it's a reason to install one for a reason.



Rule of thumb: stay on the raw SDK while you have one provider, one call site, and no Spring/DI application around the agent. Reach for LangChain4j when you want annotation-driven tools and built-in RAG abstractions without full Spring. Reach for Spring AI when the agent already lives inside a Spring Boot application and autoconfiguration, ChatClient, and @ToolParam fit the codebase's existing idioms.









The Trust Boundary Doesn't Move



Whichever path you pick, the security posture from Building Agentic Workflows in Java is unchanged: toolUse.input() (raw SDK) and the arguments a @Tool-annotated method receives (LangChain4j, Spring AI) are all the same untrusted, model-provided data. A framework generating your JSON schema does not validate the values the model sends back — calculate's whitelisted operation string still needs a default -> branch that rejects anything unexpected, regardless of which of the three call shapes above invoked it. Never string-interpolate a tool argument into a shell command or SQL query, framework or no framework.









Practical Checklist




































Practice Why it matters
Build the raw-SDK version first, even briefly Gives you a control to compare frameworks against, and a fallback if one misbehaves
Pick a framework for Spring wiring, provider portability, or built-in RAG — not for one call site The convenience win is in cross-cutting integration, not a single loop
Keep @Tool methods' validation inside the method
AiServices/ChatClient move the choke point into the tool — validation has to move with it
Verify framework APIs (annotation packages, builder methods) against current docs before shipping Framework surfaces move faster than SDK surfaces; a stale snippet is worse than none
Never build a shell/SQL string from a tool argument Prefer a whitelisted switch with a rejecting default, as calculate does here
Match dependency versions to your build (langchain4j-bom / Spring AI BOM) Both frameworks version their modules together — mixing versions is a common source of runtime errors








Final Thoughts



The raw SDK and a framework solve different problems: the SDK gives you the documented shape of one provider's API; a framework gives you an integration surface — Spring beans, a swappable chat model, a RAG abstraction — meant to stay stable as the application grows around it. For a single small agent, that stability is mostly unrealized — you pay the abstraction's overhead without yet needing what it buys. Build the raw version first so you know what the framework does on your behalf, and add LangChain4j or Spring AI only once a specific requirement asks for it by name.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Community-Diskussion & Kommentare

🌐 Zum Hauptchat

Starte die Diskussion im Social-Chat Broadcast Stream oder reiche oben über „Information ergänzen“ einen Fachbeitrag ein.

Cyber Threat Intelligence & Forensik

ATT&CK-Navigator · IoC-Radar & Graph

CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
2 Knoten · 1 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Community Rating &amp; Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War dieser Artikel hilfreich?
0
Jetzt Bewertung abgeben
Detail-Bewertung (optional)
Inhalt & Qualität
Quelle & Glaubwürdigkeit
Aktualität
Security Briefing Kostenlos · 1-Klick-Abmeldung

Intelligence Digest — kostenlos

Täglich die wichtigsten Security-News · jederzeit abbestellbar

Verwandte Story-Cluster & Quellen (Vektor-KI)

2 Cluster
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten LLM Frameworks vs. the Raw SDK in Java

Thematisch verwandte Begriffe: Frameworks, Java · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Widgets & Themen
Widgets werden geladen…
Nächster Beitrag