Bug #69948 [NEW]: path/domain are not sanitized for special characters in setcookie
| From: | neal at fb dot com | Date: | Fri, 26 Jun 2015 23:09:45 +0000 |
| Subject: | Bug #69948 [NEW]: path/domain are not sanitized for special characters in setcookie | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-193931@lists.php.net to get a copy of this message | ||
From: neal at fb dot com
Operating system: N/A
PHP version: 5.6.10
Package: HTTP related
Bug Type: Bug
Bug description:path/domain are not sanitized for special characters in setcookie
Description:
------------
In the highly unlikely event where path or domain are user-controlled,
it is possible to inject semi-colons, equals signs, etc into a value.
This allows you to provide arbitrary additional key/value pairs inside
of a Set-Cookie header (ie: set an expires header 20 years from now, add
the HttpOnly flag, etc).
There is already sanitization in the code for checking the "value"
parameter: the same logic should be applied to domain and path.
Test script:
---------------
<?php
setcookie('foo', 'bar', 0, $_GET['path'], $_GET['domain']);
Expected result:
----------------
Making a request with path=asdf;asdf&domain=foobar;%20secure results in
no cookie being sent (identical to how it's currently handled when the
value has invalid characters).
Actual result:
--------------
Header looks like Set-Cookie: foo=bar; path=asdf;asdf; domain=foobar;
secure
--
Edit bug report at https://bugs.php.net/bug.php?id=69948&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69948&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69948&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69948&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69948&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69948&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69948&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69948&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69948&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69948&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69948&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69948&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69948&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69948&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69948&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69948&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69948&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69948&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69948&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69948&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69948&r=mysqlcfg