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

[Bug] Two UAF related to redsocks_shutdown #177

Open
ShangzhiXu opened this issue Apr 3, 2023 · 0 comments
Open

[Bug] Two UAF related to redsocks_shutdown #177

ShangzhiXu opened this issue Apr 3, 2023 · 0 comments

Comments

@ShangzhiXu
Copy link

Describe the issue
I found a UAF bug in http-connection.c, in function httpc_read_cb

To Reproduce
Found it by static analysis~

Expected behavior
In this function, at line 168-169 looks like this

		redsocks_shutdown(client, client->client, SHUT_RD);
		const size_t avail = evbuffer_get_length(client->client->input);
		redsocks_shutdown(client, client->client, SHUT_RD);
		const size_t avail = evbuffer_get_length(client->client->input);
		if (avail) {
			if (evbuffer_drain(client->client->input, avail) != 0) {
				redsocks_log_errno(client, LOG_NOTICE, "evbuffer_drain");
				goto fail;
			}
		}
		redsocks_shutdown(client, client->relay, SHUT_WR);
		client->state = httpc_headers_skipped;

in redsocks_shutdown, there is a possibility of calling redsocks_drop_client(client), in redsocks.c line 790, which looks like this:

if (shut_both(client)) {
		redsocks_log_error(client, LOG_DEBUG, "both client and server disconnected");
		redsocks_drop_client(client);
	}

But after calling redsocks_shutdown above, client was visited many times. So I'm wondering if it might lead to UAF here.

Also, there is another similar problem in redsocks.c
at line 820, we called redsocks_shutdown(client, buffev, SHUT_RD); but in line 824, we visited client->state again.

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

1 participant