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

_gsskrb5_store_cred_into2 abuses putenv, likely leading to use-after-free #1163

Open
riastradh opened this issue Jun 20, 2023 · 0 comments
Open
Assignees

Comments

@riastradh
Copy link

Describe the bug
_gsskrb5_store_cred_into2 sometimes allocates an environment variable assignment with malloc:

major_status = add_env(minor_status, envp, "KRB5CCNAME", fullname);

major = gss_add_buffer_set_member(minor, &b, env);

p->value = malloc(member_buffer->length);

Then it passes this assignment to putenv:

(major_status = set_proc(minor_status, *envp)) != GSS_S_COMPLETE)

putenv(env->elements[i].value);

Then it frees the assignment:

(void) gss_release_buffer_set(&junk, &env);

gss_release_buffer(&minor, &((*buffer_set)->elements[i]));

free(buffer->value);

At this point, there is still a pointer to the freed environment variable assignment string in environ.

Subsequent calls by the same process to exec or posix_spawn will pass this pointer along. If the memory has been recycled, this may leak secrets into other processes.

To Reproduce
code inspection

Expected behavior
no putenv abuse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants