Skip to content

Client TCP proxy buffer overflow when GET request with response content-type is multipart/x-mixed-replace #13

@Pixcell

Description

@Pixcell

Hey guys :)
We are encountering an issue with tcp proxy.

This is the request: (I have removed private informations such as IP/hosts, etc)

GENERAL:
Request Method: GET
Status Code: 200 OK
Referrer Policy: no-referrer-when-downgrade

RESPONSE HEADERS:
connection: close
content-type: multipart/x-mixed-replace; boundary=frame
date: Tue, 18 Aug 2020 23:08:56 GMT
server: Werkzeug/1.0.1 Python/3.7.3
Transfer-Encoding: chunked
X-Powered-By: Express

REQUEST HEADERS:
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Pragma: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36

The proxy fails with the following logs:

2020-08-18T23:10:32.951Z iofog info *** New Mappings:  ["amqp:D3myVDqn9QDxWyth6zytqKXrgfvW7qbf=>tcp:80"]
2020-08-18T23:10:32.953Z iofog info *** Current Config:  []
2020-08-18T23:10:32.966Z iofog info *** To Delete:  []
2020-08-18T23:10:32.966Z iofog info *** To Add:  ["amqp:D3myVDqn9QDxWyth6zytqKXrgfvW7qbf=>tcp:80"]
2020-08-18T23:10:32.967Z iofog info *** Creating amqp:D3myVDqn9QDxWyth6zytqKXrgfvW7qbf=>tcp:80
[Tue Aug 18 2020 23:10:32] [LOG]   Proxying amqp:D3myVDqn9QDxWyth6zytqKXrgfvW7qbf=>tcp:80
2020-08-18T23:10:32.974Z iofog info Created AMQP to TCP bridge D3myVDqn9QDxWyth6zytqKXrgfvW7qbf => localhost:80
2020-08-18T23:10:33.247Z iofog info [raspberrypi_amqp_D3myVDqn9QDxWyth6zytqKXrgfvW7qbf_to_tcp_localhost_80] created connection scoped link route
2020-08-18T23:11:20.938Z iofog info [raspberrypi_amqp_D3myVDqn9QDxWyth6zytqKXrgfvW7qbf_to_tcp_localhost_80] receiver attached
2020-08-18T23:11:20.949Z iofog info [raspberrypi_amqp_D3myVDqn9QDxWyth6zytqKXrgfvW7qbf_to_tcp_localhost_80] receiver attached
2020-08-18T23:11:20.953Z iofog info [raspberrypi_amqp_D3myVDqn9QDxWyth6zytqKXrgfvW7qbf_to_tcp_localhost_80] socket connected to localhost:80
2020-08-18T23:11:20.955Z iofog info server tunnel created for socket 172.16.0.4:50344@undefined, amqp:/_topo/0/default-router/temp.zZYA4jR2DZ4mMWl <-> D3myVDqn9QDxWyth6zytqKXrgfvW7qbf
2020-08-18T23:11:20.956Z iofog info tcp egress connection open; metrics not enabled
2020-08-18T23:11:20.967Z iofog info [raspberrypi_amqp_D3myVDqn9QDxWyth6zytqKXrgfvW7qbf_to_tcp_localhost_80] socket connected to localhost:80
2020-08-18T23:11:20.968Z iofog info server tunnel created for socket 172.16.0.4:50342@undefined, amqp:/_topo/0/default-router/temp.oh9S2ofnISuqtFn <-> D3myVDqn9QDxWyth6zytqKXrgfvW7qbf
2020-08-18T23:11:20.968Z iofog info tcp egress connection open; metrics not enabled
[Tue Aug 18 2020 23:11:35] [ERROR] Tue, 18 Aug 2020 23:11:35 GMT Exception: circular buffer overflow: head=549 tail=549 size=2048 capacity=2048
[Tue Aug 18 2020 23:11:35] [ERROR] Error: circular buffer overflow: head=549 tail=549 size=2048 capacity=2048
    at CircularBuffer.push (/opt/app-root/node_modules/rhea/lib/session.js:56:15)
    at Outgoing.send (/opt/app-root/node_modules/rhea/lib/session.js:172:21)
    at Session.send (/opt/app-root/node_modules/rhea/lib/session.js:621:27)
    at Sender.send (/opt/app-root/node_modules/rhea/lib/link.js:334:33)
    at Server.on_socket_data (/opt/app-root/lib/tunnel.js:229:17)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:304:12)
    at readableAddChunk (_stream_readable.js:280:9)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

This only seems to happens when the response content-type is multipart/x-mixed-replace. Which is meant to be a never ending response, "streaming" content

Thank you for your help

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions