php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74168 php://input is truncated
Submitted: 2017-02-25 23:46 UTC Modified: 2017-03-12 04:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: skaownz234 at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: JSON related
PHP Version: 7.0.16 OS: Centos 7 Minimal
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: skaownz234 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-02-25 23:46 UTC] skaownz234 at gmail dot com
Description:
------------
When sending JSON via php://input, my body was truncated at the point where it read <<<<<.  It seems that this signals php to stop reading in from php://input.  The JSON parse will fail since the truncation yields invalid JSON.  I'll send the JSON blob that causes the error via the patch file.  I remove the pattern /(<|>)+/ as a work around at the moment.

Here's where it fails:

d63da06809da5cf7c712":false},"is_super_like":false,"is_boost_match":false,"person":{"_id":"56c1d63da06809da5cf7c712","badges":[],"bio":"Why do guys put their height on here? Are we more compatible the taller we are? Let\'s test it:\\n\\n4\'10\\"\\nLibra\\nSarcastic\\nENFJ\\nType A\\nAmbitious\\nSapiosexual <<<<<<<<<<'

Pretty sure the <<<'s cause this.  Seems like the underlying stream processor has some sort of break condition dependent on the < symbols.

Test script:
---------------
POST something like {

<?php
$input = file_get_contents('php://input');
$j = json_decode(stripslashes(html_entity_decode($input)), true);
echo json_encode($j);
?>

Expected result:
----------------
All JSON data is received and retrievable via my $input variable for decoding.

Actual result:
--------------
JSON is truncated at an instance of '<<<<<<<<<<', rendering it invalid.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-26 13:44 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2017-02-26 13:44 UTC] cmb@php.net
> I'll send the JSON blob that causes the error via the patch file.

That does not work. Please provide the JSON somewhere else.

Also note that the input might be truncated due to post_max_size[1].

[1] <http://php.net/manual/en/ini.core.php#ini.post-max-size>
 [2017-02-26 14:08 UTC] spam2 at rhsoft dot net
shouldn't exceed post_max_size lead in an exception instead silently truncate input data?
 [2017-03-12 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC