Skip to content
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

Does this patch have to do with memory management? #23

Open
andymeneely opened this issue Sep 25, 2024 · 0 comments
Open

Does this patch have to do with memory management? #23

andymeneely opened this issue Sep 25, 2024 · 0 comments

Comments

@andymeneely
Copy link
Contributor

One thing I've noticed is that sometimes a vulnerability patch involves making changes to code involving memory management. For example, in tmux, CVE-2020-27347, commit a868bacb46e3c900530bed47a1c6f85b0fbe701c:

diff --git a/input.c b/input.c
index 42a60c92..c280c0d9 100644
--- a/input.c
+++ b/input.c
@@ -1976,8 +1976,13 @@ input_csi_dispatch_sgr_colon(struct input_ctx *ictx, u_int i)
                                free(copy);
                                return;
                        }
-               } else
+               } else {
                        n++;
+                       if (n == nitems(p)) {
+                               free(copy);
+                               return;
+                       }
+               }
                log_debug("%s: %u = %d", __func__, n - 1, p[n - 1]);

Note that free(..) is called here, so it involved memory management. Now this CVE was mapped to CWE-121 Stack-based Buffer Overflow, so it doesn't help us here - but it might be a useful thing to look at patches and do a basic text string search for things like malloc( and free(

It'll be useful especially if we don't have CWE mapping, or might be useful some other way. Maybe casting for overflow? Anyway - interesting observation for an easy metric to collect.

@andymeneely andymeneely converted this from a draft issue Sep 25, 2024
@andymeneely andymeneely added this to the SVM paper submission milestone Sep 25, 2024
@andymeneely andymeneely added rust-discuss Issues up for discussion in our CWE to Rust mitigations manual mapping and removed rust-discuss Issues up for discussion in our CWE to Rust mitigations manual mapping labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant