Cyber Security News

Critical Vulnerabilities In Delphi Code Leads To Memory Corruption

Researchers have uncovered serious memory corruption vulnerabilities in Delphi programming language, challenging the widespread belief that Delphi provides inherent memory safety protections.

These findings highlight significant security risks that could potentially lead to application crashes, data leaks, or even remote code execution in affected software.

The vulnerabilities specifically relate to how Delphi handles memory management, particularly with arrays, strings, and object allocations.

Delphi, a dialect of Object Pascal developed initially by Borland and now maintained by Embarcadero Technologies, has been widely used in enterprise software development for decades.

The language was previously listed by the NSA in a 2023 paper on Software Memory Safety as one of the “memory safe” languages, though with caveats regarding certain unsafe functions.

Analysts at Include Security identified that despite its reputation for safety, Delphi code can be just as vulnerable to memory corruption issues as C/C++ when certain coding patterns are followed.

Their research demonstrates how seemingly innocent programming mistakes in Delphi can lead to exploitable security vulnerabilities, even with some safety mechanisms enabled.

The research team constructed multiple proof-of-concept examples to demonstrate the vulnerabilities, focusing on both stack and heap-based corruption scenarios.

Their findings show that while debug builds might catch some issues through range checking, release builds with default compiler settings can be dangerously vulnerable.

Memory Corruption

One example presented by the researchers showed a simple stack-based buffer overflow, where an attempt to write beyond the bounds of a fixed-length array could corrupt the return address on the stack when range checking was disabled:-

procedure Overflow1;
var
    ar: Array[0..9] of Byte; // Fixed-length array on the stack
    i: Integer;
begin
    for i := 0 to 999 do
    begin
        ar[i] := $41; // Try to overflow the array
    end;
end; // If overflow happens, returns to $41414141
When compiled in release mode with default settings, this code overflows the stack buffer and corrupts the return address (Source – Include Security)

The researchers also demonstrated how certain system functions like Move, FillChar, BlockRead, and BlockWrite can bypass array bounds checking even when enabled.

In another example, they showed how heap-based vulnerabilities such as use-after-free can occur when mishandling object lifetimes:-

obj1 := TMyFirstClass.Create; // Create obj1
obj1.Free; // Free obj1
obj2 := TMySecondClass.Create; // Create obj2 (occupies the same memory)
obj1.ar[4] := $41; // Write to obj1 after it's been freed, modifying obj2

The research serves as an important reminder that developers should not assume any language provides complete memory safety without proper practices and compiler settings.

Are you from SOC/DFIR Teams? – Analyse Malware Incidents & get live Access with ANY.RUN -> Start Now for Free.

Tushar Subhra Dutta

Tushar is a senior cybersecurity and breach reporter. He specializes in covering cybersecurity news, trends, and emerging threats, data breaches, and malware attacks. With years of experience, he brings clarity and depth to complex security topics.

Recent Posts

Hackers Target AI Infrastructure With RCE, Prompt Injection and API Key Theft

Hackers are actively probing AI systems, turning exposed gateways and agent tools into routes for…

4 hours ago

Hackers Make Phishing Pages Change Their Code Every Time Someone Opens Them

Hackers are making some phishing pages harder to track by changing the code delivered to…

4 hours ago

Iran-Linked Hackers Reportedly Knock UK Power Plant Offline for Four Days

A cyber incident reportedly forced a British power plant to halt operations for about four…

5 hours ago

Russian Hackers Use New HOOKEDGE Malware to Spy on European Defense and Diplomatic Targets

Russian hackers have used a new backdoor called HOOKEDGE to target defense manufacturers, government bodies,…

6 hours ago

Ransomware Gang Claims AI Can Analyze 700GB of Stolen Data Every Hour

TITAN ransomware is pairing file encryption with an ambitious claim: artificial intelligence that can sort…

6 hours ago

Hackers Compromise Hundreds of WordPress Sites to Deploy Amatera Stealer via ClickFix

A fake student resume is being used to place a remote-access tool on researchers’ Windows…

7 hours ago