0

I'm not getting that in Transfer-Encoding: chunked, how the size is counted. can anyone explain this chunk size please? thank you.

POST / HTTP/1.1
Host: your-lab-id.web-security-academy.net
Content-length: 4
Transfer-Encoding: chunked

87
GET /admin/delete?username=carlos HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 15

x=1
0
4
  • 1
    Your question and example content don't add up. There's no mention of Transfer-encoding: chunked there, not 15 bytes of data... What's that 87 at the start..? Commented Jan 27, 2021 at 7:30
  • Sorry, I just wanted the chunk size to understand, But I edited the post and it has the full request. Commented Jan 28, 2021 at 8:20
  • It still doesn't make sense. You're claiming you're sending 4 bytes of content in your Content-length header, then your chunk header says "here's 87 bytes in this chunk". Commented Jan 28, 2021 at 10:44
  • Have you read the Wikipedia article? en.wikipedia.org/wiki/Chunked_transfer_encoding#Format Commented Jan 28, 2021 at 10:46

1 Answer 1

1

When studying about http request smuggling, I struggle too in working out how the chunk size is counted. I've found the example from wikipedia to be very helpful ( https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example).

So let me try to help you out here, as this is actually a good exercise for me too.

87
GET /admin/delete?username=carlos HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 15

x=1
0

87 there is in hex form. In decimal form, its 135. Thus the chunks size is 135 bytes.

Then, for every line below 87 we count every characters (assuming 1 character equals 1 byte) and then add 2 bytes for CRLF (\r\n), except for the last line above 0 which we don't need to count the trailing CRLF.

Thus it goes something like this:

GET /admin/delete?username=carlos HTTP/1.1 -> 42 + 2 bytes for \r\n = 44 bytes
Host: localhost -> 15 + 2 = 17 bytes
Content-Type: application/x-www-form-urlencoded -> 47 + 2 = 49 bytes
Content-Length: 15 -> 18 + 2 -> 20 bytes
 -> 0 + 2 = 2 bytes
x=1 -> 3 bytes

Thus in total there are 135 bytes of chunked data.

Hope this could help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.