azure-sdk-for-c icon indicating copy to clipboard operation
azure-sdk-for-c copied to clipboard

Investigate ways to validate memory reads and writes stay within expected bounds

Open ahsonkhan opened this issue 4 years ago • 1 comments

The goal is to harden the APIs and improve reliability.

  • Scrutinize and review closely parts of the code that does buffer manipulation via direct pointers to make sure they are within bounds
  • Leverage sentinel values in buffers used within tests to ensure there are no out-of-bounds writes. For example: https://github.com/Azure/azure-sdk-for-c/blob/df0b4153badc92ac42e9477dc23af6b9df994ee5/sdk/core/core/test/inc/az_test_span.h#L37-L42
  • Consider some approach where memory is somehow marked as non-executabe/non-accessible within special tests, so that out-of-bounds reads are detected.

Some examples of things to review: https://github.com/Azure/azure-sdk-for-c/blob/df0b4153badc92ac42e9477dc23af6b9df994ee5/sdk/core/core/src/az_http_response.c#L171 https://github.com/Azure/azure-sdk-for-c/blob/28359d59358d4609cadcc3446974b15084313149/sdk/core/core/src/az_span.c#L709

Most places use az_span APIs (which can be considered safe and consolidated to one place), but any that drop-down to pointers, should be looked at (for example when using az_span_ptr). https://github.com/Azure/azure-sdk-for-c/search?q=az_span_ptr&unscoped_q=az_span_ptr

ahsonkhan avatar May 11 '20 21:05 ahsonkhan

cc @JeffreyRichter, @gilbertw, @vhvb1989, @antkmsft

ahsonkhan avatar May 11 '20 22:05 ahsonkhan

Hi @ahsonkhan, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.

github-actions[bot] avatar Mar 15 '24 18:03 github-actions[bot]