Skip to content

Fix broken files upload on php > 5.6.0 #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2016
Merged

Fix broken files upload on php > 5.6.0 #52

merged 2 commits into from
Feb 27, 2016

Conversation

shmaltorhbooks
Copy link

CURLOPT_SAFE_UPLOAD - TRUE to disable support for the @ prefix for uploading files in CURLOPT_POSTFIELDS.

Added in PHP 5.5.0 with FALSE as the default value. PHP 5.6.0 changes the default value to TRUE.

http://php.net/manual/ru/function.curl-setopt.php

@shmaltorhbooks
Copy link
Author

ping

@aik099
Copy link
Member

aik099 commented Feb 27, 2016

Sorry for the delay, @shmaltorhbooks . I suppose you're trying to upload a file with @ in it's name and this doesn't work?

@aik099
Copy link
Member

aik099 commented Feb 27, 2016

According to https://bugs.php.net/bug.php?id=66677 enabling this option by default would also wrong security-wise because anyone that can pass POST parameters can upload local files on the system through it.

@@ -71,6 +71,9 @@ public function sendRequest($method, $url, $data = array(), $endpoint, Authentic
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_VERBOSE, $debug);
if ($isFile) {
if (defined('CURLOPT_SAFE_UPLOAD')) {
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. Documentation for this option says this:

TRUE to disable support for the @ prefix for uploading files in CURLOPT_POSTFIELDS, which means that values starting with @ can be safely passed as fields. CURLFile may be used for uploads instead.

so the value false is enabling unsafe mode, that allows @ usage for filename uploads.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now. The createAttachment method uses @ for file upload according to https://docs.atlassian.com/jira/REST/latest/#api/2/issue/{issueIdOrKey}/attachments-addAttachment .

Then it's OK for now, but might be bad in long term from security point of view when an attacker has control over name of the filename, that is uploaded it can trick CURL into uploading any other expect specified file.

jpastoor added a commit that referenced this pull request Feb 27, 2016
Fix broken files upload on php > 5.6.0
@jpastoor jpastoor merged commit 7cda7c6 into console-helpers:master Feb 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants