Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2024-5452 | Kitploit
Tools/GitHubGitHub/skrkcb2/cve-2024-5452
Vulnerability AnalysisCode AnalysisExploitationWeb Application ExploitationLearning & EducationAI Security
GitHubskrkcb2/cve-2024-5452

CVE-2024-5452

View Repository
1 year agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2024-5452

01. Overview of RCE and pytorch-lightning

  • 1) Overview of RCE and pytorch-lightning

    RCE (Remote Code Execution) is a vulnerability that allows an attacker to execute arbitrary code remotely within a system or application, and is classified as CWE-94: Improper Control of Generation of Code ('Code Injection').

    PyTorch Lightning is a library that helps easily manage deep learning model training based on PyTorch, and DeepDiff is a library that analyzes differences by comparing two Python objects.

    CVE-2024-5452 is a vulnerability that causes RCE during deserialization through weak header validation of DeepDiff and delta attribute contamination in the process of utilizing DeepDiff and Lightning in Lightning's AI model weight-related web application features.

    Through this, we will examine the code flow that leads to vulnerabilities allowing an attacker to inject arbitrary objects or perform remote code execution (RCE), and explore countermeasures.

02. Analysis of Deserialization Vulnerability in pytorch-lightning Environment

  • 2.1 Attack Analysis Using Delta Contamination in DeepDiff

    In pytorch-lightning, among the DeepDiff endpoints of the web application source, it is possible to attack by contaminating the delta attribute and sending it to /api/v1/delta.
    Through examples, we aim to understand how contaminating the delta's dunder attributes induces an object deserialization vulnerability.

    1) Attack Flow Using Delta Contamination in DeepDiff

    The first request consists of: Client attack example, contamination setup -> Weak header validation in Deepdiff's /api/v1/delta -> State storage via contamination setup.

    Image description

    [Figure 1] POC - Endpoint attack

    Image description

    [Figure 2] POC - Vuln Injection / Full contamination setup content

    Image description

    [Figure 3] lightning/api/core/api.py / Weak header validation logic part

    Image description

    [Figure 4] lightning/api/core/app.py / Setup section

    Image description

    [Figure 5] lightning/api/core/app.py / State storage section

    In the first request, the header validation of /api/v1/delta in [Figure 3] is bypassed via [Figure 1], then a manipulated contamination setup (delta) [Figure 2] is injected, and the setup is saved through [Figure 4] and [Figure 5]. Now let's look at how these manipulated delta settings work in the second request.

    Image description Image description

    [Figure 6] lightning/api/core/app.py / Initial path flow

    [Figure 6] shows the flow of the second request after delta is set: run_once() -> maybe_apply_change() -> _collect_deltas_from_ui_and_work_queues()

    Image description

    [Figure 7] isinstance contamination case

    [Figure 7] In _collect_deltas_from_ui_and_work_queues(), the isinstance check is bypassed using contaminated settings (isinstance(delta, _DeltaRequest) == False), causing execution to go to else.

    Image description

    [Figure 8] isinstance contamination case 1

    [Figure 8] For better understanding, the results of isinstance(delta, _DeltaRequest), delta, and _DeltaRequest(type) are shown. The first request is a setup request for manipulation, so it is normal; the next request bypasses the condition because _DeltaRequest type is contaminated to str. Next, let's look at an example of the next target, _process_requests.

    Image description

    [Figure 9] isinstance contamination case 2

    As seen in [Figure 9], with the same content as above, _process_requests bypasses the isinstance(request, _APIRequest) check using contaminated settings from the client POC code on the right. This contamination is a case where isinstance call on an OrderSet instance for str returns true. We have seen two forms of isinstance contamination so far; afterward, the settings are crafted to allow accessing attributes through contamination.

    Image description

    Image description

    Image description

    [Figure 10] isinstance contamination case 3

    After bypassing isinstance in [Figure 10] and setting up functions, set "_INTERNAL_STATE_VARS: () to empty" in [Figure 10], making it impossible to verify internal state in [Figure 11].

    Image description

    [Figure 11_1] _INTERNAL_STATE_VARS check function in /lightning/app/core/flow.py

    Image description

    [Figure 11_2] __setattr__ in /lightning/app/core/flow.py

    With [Figure 11] as the last step, the overall contamination and setup are complete.

    Image description

    [Figure 12] RCE Command

    Image description

    Image description

    [Figure 13] RCE Response

    Finally, in [Figure 13], exec with root privileges is called to execute the command in [Figure 12], concluding the attack.

2) Brief Example of Attack Using Delta Contamination in DeepDiff (Left: Lightning App server, Right: Client)

Image description

03. Countermeasures

So far, we have examined the flow of RCE vulnerability through object deserialization (CVE-2024-5452) in the Lightning environment. Since this is an attack method that compromises the server itself, countermeasures are important. To this end, we propose updating to the latest version.

  • Lightning Update

    If lightning <= 2.2.1, please update to lightning version > 2.3.3 or higher.
  • Simple Lightning Library Modification

    This method is a temporary fix for unavoidable cases, so please consider it as a reference. Add simple logic to the /api/v1/delta endpoint (path /lightning/app/core/api) or strengthen the session check part above. depence
  • Detection and Blocking via IPS

    The attack was tested by specifying dunder attributes in JSON via Postman. image 20250210_143207

04. Conclusion

We have examined the vulnerability that causes RCE by contaminating Dunder attributes through Lightning and Deepdiff. This vulnerability occurred first due to weak header validation, followed by weak delta attribute checking leading to object deserialization.

05. References

(poc) https://security.snyk.io/vuln/SNYK-PYTHON-PYTORCHLIGHTNING-7218866
(nist) https://nvd.nist.gov/vuln/detail/CVE-2024-5452

Download Tool