-
Notifications
You must be signed in to change notification settings - Fork 14
Issue 79: Detect use-after-free in sa_invoke #80
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,3 +132,29 @@ Sec_Result testProcessorInitReleaseInit() { | |
|
|
||
| return SEC_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| Sec_Result testProcessorUseAfterFree() { | ||
| Sec_ProcessorHandle* proc = nullptr; | ||
| if (SecProcessor_GetInstance_Directories(&proc, nullptr, nullptr) != SEC_RESULT_SUCCESS) { | ||
| SEC_LOG_ERROR("SecProcessor_GetInstance_Directories failed"); | ||
| return SEC_RESULT_FAILURE; | ||
| } | ||
|
|
||
| // Save the handle pointer before releasing | ||
| Sec_ProcessorHandle* dangling = proc; | ||
|
|
||
| if (SecProcessor_Release(proc) != SEC_RESULT_SUCCESS) { | ||
| SEC_LOG_ERROR("SecProcessor_Release failed"); | ||
| return SEC_RESULT_FAILURE; | ||
| } | ||
|
|
||
| // Attempt to use the freed handle - sa_invoke should detect this and return failure | ||
| Sec_Result result = SecKey_Generate(dangling, SEC_OBJECTID_USER_BASE, SEC_KEYTYPE_AES_128, | ||
| SEC_STORAGELOC_RAM); | ||
| if (result == SEC_RESULT_SUCCESS) { | ||
| SEC_LOG_ERROR("SecKey_Generate should have failed on a freed handle"); | ||
| return SEC_RESULT_FAILURE; | ||
|
Comment on lines
+151
to
+156
|
||
| } | ||
|
|
||
| return SEC_RESULT_SUCCESS; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.