X Tutup
Skip to content

Perform input validation on DAP requests#115285

Open
rsubtil wants to merge 3 commits intogodotengine:masterfrom
rsubtil:fix-dap_unsafe_access
Open

Perform input validation on DAP requests#115285
rsubtil wants to merge 3 commits intogodotengine:masterfrom
rsubtil:fix-dap_unsafe_access

Conversation

@rsubtil
Copy link
Member

@rsubtil rsubtil commented Jan 22, 2026

Closes #115279

Recent changes in Godot revealed a bad implementation of the DAP specification, where we tried to always access the checksums property of DAP::Source objects, when these are actually optional.

To fix this and prevent other scenarios like these, the whole implementation was reviewed (similar to #111684, #112128), handling input validation at two levels:

  • For fields declared as mandatory by the specification, VALIDATE_KEY tests the key existence and the expected type. If the check fails, an error is logged in Godot (ERR_FAIL) and a DAP::ErrorRequest with error type MALFORMED_REQUEST is sent, both with information on the failed validation step.
  • For fields declared as optional by the specification (with ?), changed Dictionary access to the safe get() call with default values.

@rsubtil rsubtil requested a review from a team as a code owner January 22, 2026 22:36
@AThousandShips AThousandShips added this to the 4.x milestone Jan 23, 2026
}

Array breakpoints = args["breakpoints"], lines;
Array breakpoints = args.get("breakpoints", Array()), lines;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Array breakpoints = args.get("breakpoints", Array()), lines;
Array breakpoints = args.get("breakpoints", Array());
Array lines;

While we're here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there are still a lot of instances of this in DAP, so I can go ahead and fix all of them in one go.

Copy link
Member Author

@rsubtil rsubtil Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed (3027e56)

if (!response["success"]) {
response["command"] = p_params["command"];
if (!(bool)response.get("success", false)) {
response["command"] = p_params["command"]; // No need to validate if "command" exists; this is done when any request is received
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
response["command"] = p_params["command"]; // No need to validate if "command" exists; this is done when any request is received
response["command"] = p_params["command"]; // No need to validate that "command" exists; this is done when any request is received.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@rsubtil rsubtil force-pushed the fix-dap_unsafe_access branch from b99e27c to 3027e56 Compare January 23, 2026 17:36
@Repiteo Repiteo requested a review from a team as a code owner February 17, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perform input validation on DAP requests

2 participants

X Tutup