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

Fix issues with boundary access. #6019

Merged
merged 16 commits into from Apr 6, 2020
Merged

Conversation

akallabeth
Copy link
Member

No description provided.

@akallabeth akallabeth added this to the 2.0.0 milestone Apr 2, 2020
@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4756/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4757/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4758/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4759/

@@ -2161,7 +2161,7 @@ static CACHE_BITMAP_V3_ORDER* update_read_cache_bitmap_v3_order(rdpUpdate* updat
Stream_Read_UINT16(s, bitmapData->height); /* height (2 bytes) */
Stream_Read_UINT32(s, new_len); /* length (4 bytes) */

if (Stream_GetRemainingLength(s) < new_len)
if ((new_len == 0) || (Stream_GetRemainingLength(s) < new_len))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might misinterpret the spec but a length of 0 could be possible (2.2.9.2.1.1 Extended Bitmap Data ).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe in theory, but an empty bitmap could break a lot later on and does not make much sense.

*channel_id = 0;
*length = 8; /* Flow control PDU is 8 bytes */
return TRUE;
}

if (((size_t)*length - 2) > Stream_GetRemainingLength(s))
if ((len < 4) || ((len - 2) > Stream_GetRemainingLength(s)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for the len < 4?

Copy link
Member Author

@akallabeth akallabeth Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the header length required (the 2 bytes length itself and 2 bytes type)

bmiklautz
bmiklautz previously approved these changes Apr 2, 2020
{
WLog_ERR(TAG,
"incorrect offset, type:0x%04" PRIX16 " actual:%" PRIuz " expected:%" PRIuz "",
type, Stream_Pointer(s) - bm, em - bm);
type, length + rest, length);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: here instead of printing the offset which is useless we could just show the remaining bytes...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what @hardening wrote, just show how many bytes were not handled

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already done in latest commit.

@@ -1384,7 +1393,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
"pduType %s not properly parsed, %" PRIdz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could include my patch (gist sent on IRC), as it fixes the fact that you can announce a small pduLength but decoding functions will be able to read more than pduLength (because they do checks with Stream_GetRemainingLength(mainStream))

hardening
hardening previously approved these changes Apr 3, 2020
Copy link
Contributor

@hardening hardening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some remark, but LGTM, nice job.
The code is so much simpler when using substreams !

@akallabeth
Copy link
Member Author

@hardening will address your comments in a separate PR, I think better merge this now as it is already big enough.

@akallabeth akallabeth dismissed stale reviews from hardening and bmiklautz via a022958 April 3, 2020 13:11
@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4766/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4767/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4768/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4769/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4770/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/4771/

Copy link
Contributor

@nfedera nfedera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice job

@nfedera nfedera merged commit c367f65 into FreeRDP:master Apr 6, 2020
@akallabeth akallabeth deleted the bound_access_fixes branch April 6, 2020 11:53
@akallabeth akallabeth linked an issue Apr 6, 2020 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

memory out of bounds read in rdp_read_share_control_header
5 participants