-
Notifications
You must be signed in to change notification settings - Fork 469
fix(iast): wrong memory address in subprocess in mcp servers #15514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
avara1986
wants to merge
20
commits into
main
Choose a base branch
from
avara1986/APPSEC-60135_iast_potencial_error
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
578f47c
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 061b01e
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 5105588
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 750d831
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 9f2a3cf
enable tests for python 3.14
avara1986 54aec7d
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 968863b
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 95c4163
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 30f8559
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 d7d49e4
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 6f80cb9
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 8f51f9b
Merge branch 'main' into avara1986/APPSEC-60135_iast_potencial_error
avara1986 ee17762
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 524f55a
fix(iast): wrong memory address in subprocess in MCP servers
avara1986 fcf83f2
codestyle
avara1986 05a9d46
rollback
avara1986 364dde0
codestyle
avara1986 83a1467
fix slice aspect memory usage
avara1986 0104ab5
fix slice aspect memory usage
avara1986 f396595
increment slo
avara1986 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #include "api/safe_context.h" | ||
|
|
||
| // ============================================================================ | ||
| // Safe wrapper functions for global pointers | ||
| // ============================================================================ | ||
| // These functions centralize null checks for taint_engine_context and | ||
| // initializer to prevent segmentation faults when called before | ||
| // initialize_native_state(). All aspect functions should use these wrappers | ||
| // instead of accessing the globals directly. | ||
| TaintedObjectMapTypePtr | ||
| safe_get_tainted_object_map(PyObject* tainted_object) | ||
| { | ||
| if (!taint_engine_context) { | ||
| return nullptr; | ||
| } | ||
| return taint_engine_context->get_tainted_object_map(tainted_object); | ||
| } | ||
|
|
||
| TaintedObjectMapTypePtr | ||
| safe_get_tainted_object_map_from_list_of_pyobjects(const std::vector<PyObject*>& objects) | ||
| { | ||
| if (!taint_engine_context) { | ||
| return nullptr; | ||
| } | ||
| return taint_engine_context->get_tainted_object_map_from_list_of_pyobjects(objects); | ||
| } | ||
|
|
||
| TaintedObjectMapTypePtr | ||
| safe_get_tainted_object_map_by_ctx_id(size_t ctx_id) | ||
| { | ||
| if (!taint_engine_context) { | ||
| return nullptr; | ||
| } | ||
| return taint_engine_context->get_tainted_object_map_by_ctx_id(ctx_id); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #pragma once | ||
| #include "context/taint_engine_context.h" | ||
|
|
||
| // Safe wrapper functions that check for null before accessing global pointers | ||
| // These functions centralize null checks to prevent segmentation faults when | ||
| // called before initialize_native_state() | ||
|
|
||
| /** | ||
| * @brief Safely get tainted object map for a PyObject. | ||
| * @param tainted_object The Python object to look up | ||
| * @return TaintedObjectMapTypePtr or nullptr if not initialized or not found | ||
| */ | ||
| TaintedObjectMapTypePtr | ||
| safe_get_tainted_object_map(PyObject* tainted_object); | ||
|
|
||
| /** | ||
| * @brief Safely get tainted object map by context ID. | ||
| * @param ctx_id The context ID to look up | ||
| * @return TaintedObjectMapTypePtr or nullptr if not initialized or not found | ||
| */ | ||
| TaintedObjectMapTypePtr | ||
| safe_get_tainted_object_map_by_ctx_id(size_t ctx_id); | ||
|
|
||
| /** | ||
| * @brief Safely get tainted object map from a list of PyObjects. | ||
| * @param objects Vector of PyObject pointers to search | ||
| * @return TaintedObjectMapTypePtr or nullptr if not initialized or not found | ||
| */ | ||
| TaintedObjectMapTypePtr | ||
| safe_get_tainted_object_map_from_list_of_pyobjects(const std::vector<PyObject*>& objects); |
46 changes: 46 additions & 0 deletions
46
ddtrace/appsec/_iast/_taint_tracking/api/safe_initializer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #include "api/safe_initializer.h" | ||
|
|
||
| TaintRangePtr | ||
| safe_allocate_taint_range(RANGE_START start, RANGE_LENGTH length, const Source& source, const SecureMarks secure_marks) | ||
| { | ||
| if (!initializer) { | ||
| return nullptr; | ||
| } | ||
| return initializer->allocate_taint_range(start, length, source, secure_marks); | ||
| } | ||
|
|
||
| TaintedObjectPtr | ||
| safe_allocate_tainted_object_copy(const TaintedObjectPtr& from) | ||
avara1986 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if (!initializer) { | ||
| return nullptr; | ||
| } | ||
| return initializer->allocate_tainted_object_copy(from); | ||
| } | ||
|
|
||
| TaintedObjectPtr | ||
| safe_allocate_tainted_object() | ||
avara1986 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if (!initializer) { | ||
| return nullptr; | ||
| } | ||
| return initializer->allocate_tainted_object(); | ||
| } | ||
|
|
||
| TaintedObjectPtr | ||
| safe_allocate_ranges_into_taint_object(TaintRangeRefs ranges) | ||
| { | ||
| if (!initializer) { | ||
| return nullptr; | ||
| } | ||
| return initializer->allocate_ranges_into_taint_object(ranges); | ||
| } | ||
|
|
||
| TaintedObjectPtr | ||
| safe_allocate_ranges_into_taint_object_copy(const TaintRangeRefs& ranges) | ||
| { | ||
| if (!initializer) { | ||
| return nullptr; | ||
| } | ||
| return initializer->allocate_ranges_into_taint_object_copy(ranges); | ||
| } | ||
49 changes: 49 additions & 0 deletions
49
ddtrace/appsec/_iast/_taint_tracking/api/safe_initializer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #pragma once | ||
|
|
||
| #include "initializer/initializer.h" | ||
| #include <Python.h> | ||
|
|
||
| /** | ||
| * @brief Safely allocate a taint range. | ||
| * @param start The start position of the taint range | ||
| * @param length The length of the taint range | ||
| * @param source The source of the taint | ||
| * @param secure_marks Optional secure marks | ||
| * @return TaintRangePtr or nullptr if not initialized | ||
| */ | ||
| TaintRangePtr | ||
| safe_allocate_taint_range(RANGE_START start, | ||
| RANGE_LENGTH length, | ||
| const Source& source, | ||
| const SecureMarks secure_marks = 0); | ||
|
|
||
| /** | ||
| * @brief Safely allocate a copy of a tainted object. | ||
| * @param from The tainted object to copy | ||
| * @return TaintedObjectPtr or nullptr if not initialized | ||
| */ | ||
| TaintedObjectPtr | ||
| safe_allocate_tainted_object_copy(const TaintedObjectPtr& from); | ||
|
|
||
| /** | ||
| * @brief Safely allocate a tainted object. | ||
| * @return TaintedObjectPtr or nullptr if not initialized | ||
| */ | ||
| TaintedObjectPtr | ||
| safe_allocate_tainted_object(); | ||
|
|
||
| /** | ||
| * @brief Safely allocate ranges into a tainted object. | ||
| * @param ranges The ranges to allocate | ||
| * @return TaintedObjectPtr or nullptr if not initialized | ||
| */ | ||
| TaintedObjectPtr | ||
| safe_allocate_ranges_into_taint_object(TaintRangeRefs ranges); | ||
|
|
||
| /** | ||
| * @brief Safely allocate a copy of ranges into a tainted object. | ||
| * @param ranges The ranges to copy and allocate | ||
| * @return TaintedObjectPtr or nullptr if not initialized | ||
| */ | ||
| TaintedObjectPtr | ||
| safe_allocate_ranges_into_taint_object_copy(const TaintRangeRefs& ranges); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #define CHECK_IAST_INITIALIZED_OR_RETURN(fallback_result) \ | ||
| if (!taint_engine_context || !initializer) { \ | ||
| return fallback_result; \ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| #pragma once | ||
|
|
||
| #include "initializer/initializer.h" | ||
| #include <Python.h> | ||
| #include "api/safe_context.h" | ||
| #include "api/safe_initializer.h" | ||
|
|
||
| PyObject* | ||
| api_extend_aspect(PyObject* self, PyObject* const* args, Py_ssize_t nargs); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.