Skip to content

Process hangs when injecting large code blocks using Runtime.evaluate #428

@sudharsan-selvaraj

Description

@sudharsan-selvaraj

I'm trying to inject huge javascript code using the below CDP command(Size of the script is around 250KB)

{
  "id": 76,
  "method": "Target.sendMessageToTarget",
  "params": {
    "message": "{\"id\":75,\"method\":\"Runtime.evaluate\",\"params\":{\"expression\":\" function(){ very large code } \",\"contextId\":25,\"returnByValue\":false}}",
    "targetId": "page-493"
  }
}

Logs from ios_webkit_debug_proxy with -d

 00 04 9B F7 62 70 6C 69 73 74 30 30 D2 01 03 02 04 5A 5F  ....bplist00.....Z_
 5F 73 65 6C 65 63 74 6F 72 5F 10 17 5F 72 70 63 5F 66 6F  _selector_.._rpc_fo
 72 77 61 72 64 53 6F 63 6B 65 74 44 61 74 61 3A 5A 5F 5F  rwardSocketData:Z__
 61 72 67 75 6D 65 6E 74 D5 05 07 09 0B 0D 06 08 0A        argument.........
 0C 0E 5F 10 1A 57 49 52 43 6F 6E 6E 65 63 74 69 6F 6E 49  .._..WIRConnectionI
 64 65 6E 74 69 66 69 65 72 4B 65 79 5F 10 24 33 34 31 34  dentifierKey_.$3414
 30 33 43 41 2D 39 35 42 35 2D 34 38 37 34 2D 38 30 30 39  03CA-95B5-4874-8009
 2D 34 44 31 31 39 45 34 36 41 41 33 35 5F 10 1B 57 49 52  -4D119E46AA35_..WIR
 41 70 70 6C 69 63 61 74 69 6F 6E 49 64 65 6E 74 69 66 69  ApplicationIdentifi
 65 72 4B 65 79 58 50 49 44 3A 31 34 36 32 5F 10 14 57 49  erKeyXPID:1462_..WI
 52 50 61 67 65 49 64 65 6E 74 69 66 69 65 72 4B 65 79 10  RPageIdentifierKey.
 03 5C 57 49 52 53 65 6E 64 65 72 4B 65 79 5F 10 24 42 34  .\WIRSenderKey_.$B4
 39 45 33 46 37 32 2D 38 30 45 38 2D 34 42 41 33 2D 41 39  9E3F72-80E8-4BA3-A9
 36 43 2D 43 36 46 45 38 39 33 35 43 34 44 43 5F 10 10 57  6C-C6FE8935C4DC_..W
 49 52 53 6F 63 6B 65 74 44 61 74 61 4B 65 79 4F 12 00 04  IRSocketDataKeyO...
 9A 91 7B 22 69 64 22 3A 37 36 2C 22 6D 65 74 68 6F 64 22  ..{"id":76,"method"
 3A 22 54 61 72 67 65 74 2E 73 65 6E 64 4D 65 73 73 61 67  :"Target.sendMessag
 65 54 6F 54 61 72 67 65 74 22 2C 22 70 61 72 61 6D 73 22  eToTarget","params"
 3A 7B 22 6D 65 73 73 61 67 65 22 3A 22 7B 5C 22 69 64 5C  :{"message":"{\"id\
 22 3A 37 35 2C 5C 22 6D 65 74 68 6F 64 5C 22 3A 5C 22 52  ":75,\"method\":\"R
 75 6E 74 69 6D 65 2E 65 76 61 6C 75 61 74 65 5C 22 2C 5C  untime.evaluate\",\
 22 70 61 72 61 6D 73 5C 22 3A 7B 5C 22 65 78 70 72 65 73  "params\":{\"expres
 73 69 6F 6E 5C 22 3A 5C 22 5C 5C 6E 20 20 20 20 20 20 20  sion\":\"\\n       
 20 28 28 29 20 3D 3E 20 7B 5C 5C 6E 20 20 20 20 20 20 20   (() => {\\n       
 20 63 6F 6E 73 74 20 6D 6F 64 75 6C 65 20 3D 20 7B 7D 3B   const module = {};
 5C 5C 6E 20 20 20 20 20 20 20 20 5C 5C 6E 76 61 72 20 5F  \\n        \\nvar _
 5F 63 6F 6D 6D 6F 6E 4A 53 20 3D 20 6F 62 6A 20 3D 3E 20  _commonJS = obj => 
 7B 5C 5C 6E 20 20 6C 65 74 20 72 65 71 75 69 72 65 64 20  {\\n  let required 
 3D 20 66 61 6C 73 65 3B 5C 5C 6E 20 20 6C 65 74 20 72 65  = false;\\n  let re
 73 75 6C 74 3B 5C 5C 6E 20 20 72 65 74 75 72 6E 20 66 75  sult;\\n  return fu
 6E 63 74 69 6F 6E 20 5F 5F 72 65 71 75 69 72 65 28 29 20  nction __require()  +301488
ss.sendq<0x600003c64720> new fd=9 recv_fd=8 length=187387, prev=<0x0>
ss.sendq<0x600003c64720> disable recv_fd=8
ss.sendq<0x600003c64720> resume send to fd=9 len=187387
ss.sendq<0x600003c64720> defer len=154619
ss.sendq<0x600003c64720> resume send to fd=9 len=154619
ss.sendq<0x600003c64720> defer len=121851
ss.sendq<0x600003c64720> resume send to fd=9 len=121851
ss.sendq<0x600003c64720> defer len=89083
ss.sendq<0x600003c64720> resume send to fd=9 len=89083
ss.sendq<0x600003c64720> defer len=56315
ss.sendq<0x600003c64720> resume send to fd=9 len=56315
ss.sendq<0x600003c64720> defer len=23547
ss.sendq<0x600003c64720> resume send to fd=9 len=23547
ss.sendq<0x600003c64720> re-enable recv_fd=8
ss.sendq<0x600003c64720> free, next=<0x0>

Once the message is dispatched, the server neither acknowledges it nor processes any subsequent messages from the client

Metadata

Metadata

Assignees

No one assigned

    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