Cross Site Scripting in image upload. #551

Closed
opened 2026-10-05 00:03:30 +02:00 by adam · 13 comments
Owner

Latest Version of piwigo is vulnerable to cross site scripting vulnerability in the image upload function,
The filename of image can be crafted with malicious payload,which in turn executes while viewing the image.


HTTP REQUEST:

POST /piwigo2/piwigo2/ws.php?method=pwg.images.upload&format=json HTTP/1.1
Host: x.x.x.x:xxxx
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://x.x.x.x:xxxx/piwigo2/piwigo2/admin.php?page=photos_add
Content-Length: 437474
Content-Type: multipart/form-data; boundary=---------------------------2133695097524014491600710750
Cookie: pwg_id=5bcim9rvd29i0grbe3qqg4qlk4; PHPSESSID=8e7766b7fc68cc81ee8cb8858dba1b1e; cid=1; wordpress_logged_in_8812ad623e46a1e5ebc36bb4a144d4be=admin%7C1484115709%7CSYNChB5ZsITQYFlPiW5bspgix97gGEwr05932gvtGtp%7Cda8b8a3479779d07c9d1759a52b8e52a7168da7170b66a093ff5ea93a09ec453
Connection: close

-----------------------------2133695097524014491600710750
Content-Disposition: form-data; name="name"

test
-----------------------------2133695097524014491600710750
Content-Disposition: form-data; name="chunk"

0
-----------------------------2133695097524014491600710750
Content-Disposition: form-data; name="chunks"

1
-----------------------------2133695097524014491600710750
Content-Disposition: form-data; name="category"

1
-----------------------------2133695097524014491600710750
Content-Disposition: form-data; name="level"

0
-----------------------------2133695097524014491600710750
Content-Disposition: form-data; name="pwg_token"

d0cc011709eb9b873188071ab872ebe7
-----------------------------2133695097524014491600710750
Content-Disposition: form-data; name="file"; filename="payloadhere.png"
Content-Type: image/png

Malicious script can be passed in the payloadhere section

Latest Version of piwigo is vulnerable to cross site scripting vulnerability in the image upload function, The filename of image can be crafted with malicious payload,which in turn executes while viewing the image. ----------------------- HTTP REQUEST: ----------------------- POST /piwigo2/piwigo2/ws.php?method=pwg.images.upload&format=json HTTP/1.1 Host: x.x.x.x:xxxx User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://x.x.x.x:xxxx/piwigo2/piwigo2/admin.php?page=photos_add Content-Length: 437474 Content-Type: multipart/form-data; boundary=---------------------------2133695097524014491600710750 Cookie: pwg_id=5bcim9rvd29i0grbe3qqg4qlk4; PHPSESSID=8e7766b7fc68cc81ee8cb8858dba1b1e; cid=1; wordpress_logged_in_8812ad623e46a1e5ebc36bb4a144d4be=admin%7C1484115709%7CSYNChB5ZsITQYFlPiW5bspgix97gGEwr05932gvtGtp%7Cda8b8a3479779d07c9d1759a52b8e52a7168da7170b66a093ff5ea93a09ec453 Connection: close -----------------------------2133695097524014491600710750 Content-Disposition: form-data; name="name" test -----------------------------2133695097524014491600710750 Content-Disposition: form-data; name="chunk" 0 -----------------------------2133695097524014491600710750 Content-Disposition: form-data; name="chunks" 1 -----------------------------2133695097524014491600710750 Content-Disposition: form-data; name="category" 1 -----------------------------2133695097524014491600710750 Content-Disposition: form-data; name="level" 0 -----------------------------2133695097524014491600710750 Content-Disposition: form-data; name="pwg_token" d0cc011709eb9b873188071ab872ebe7 -----------------------------2133695097524014491600710750 Content-Disposition: form-data; name="file"; filename="**payloadhere**.png" Content-Type: image/png **Malicious script can be passed in the payloadhere section** <!-- github-sync-id:198632595 -->
adam closed this issue 2026-10-05 00:03:30 +02:00
Author
Owner

Hi @boogyman2 can you please send me an email with more details? "plg" /at/ "piwigo.org"

Hi @boogyman2 can you please send me an email with more details? "plg" /at/ "piwigo.org" <!-- github-comment-id:270358190 -->
Author
Owner

Hello
I'm the one with the lowest skill here ; so you need to be
1- to be logged as admin
2- to send a picture through an home made POST request just like the one at admin.php?page=photos_add
3- but I don't get the final step

Hello I'm the one with the lowest skill here ; so you need to be 1- to be logged as admin 2- to send a picture through an home made POST request just like the one at admin.php?page=photos_add 3- but I don't get the final step <!-- github-comment-id:270358275 -->
Author
Owner

Hi @plegall yea sure,I'll put up a mail.
@plegall Mail sent,with details.Check it out.

Hi @plegall yea sure,I'll put up a mail. @plegall Mail sent,with details.Check it out. <!-- github-comment-id:270572053 -->
Author
Owner

up?

up? <!-- github-comment-id:272268427 -->
Author
Owner

Hi, @flop25 No Response from @plegall yet, i had sent him a an email explaining the vulnerability.

Hi, @flop25 No Response from @plegall yet, i had sent him a an email explaining the vulnerability. <!-- github-comment-id:272783989 -->
Author
Owner

you up ? @plegall

you up ? @plegall <!-- github-comment-id:275601132 -->
Author
Owner

I admit I don't really like to modify the original filename.

If you use the web upload form, you execute the javascript in file name, but it is not "stored", so it's not a real problem.

I admit I don't really like to modify the original filename. If you use the web upload form, you execute the javascript in file name, but it is not "stored", so it's not a real problem. <!-- github-comment-id:275632292 -->
Author
Owner

Maybe it's enough to check during upload that the given filename does not
contain < > (invalid for both Windows /Linux)

On Jan 27, 2017 11:16, "Pierrick Le Gall" notifications@github.com wrote:

I admit I don't really like to modify the original filename.

If you use the web upload form, you execute the javascript in file name,
but it is not "stored", so it's not a real problem.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Piwigo/Piwigo/issues/600#issuecomment-275632292, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJRc9mK6jeUSNHb2DCdf3_dQT18Gdon7ks5rWcPagaJpZM4LaTPq
.

Maybe it's enough to check during upload that the given filename does not contain < > (invalid for both Windows /Linux) On Jan 27, 2017 11:16, "Pierrick Le Gall" <notifications@github.com> wrote: > I admit I don't really like to modify the original filename. > > If you use the web upload form, you execute the javascript in file name, > but it is not "stored", so it's not a real problem. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/Piwigo/Piwigo/issues/600#issuecomment-275632292>, or mute > the thread > <https://github.com/notifications/unsubscribe-auth/AJRc9mK6jeUSNHb2DCdf3_dQT18Gdon7ks5rWcPagaJpZM4LaTPq> > . > <!-- github-comment-id:275637452 -->
Author
Owner

@plegall the xss is stored one..A victim viewing the image with payload itself is necessary to infect him/her. What if an attacker uplaods the crafted image and sends victim the link. Suggestion by @modus75 is good one to consider.

@plegall the xss is stored one..A victim viewing the image with payload itself is necessary to infect him/her. What if an attacker uplaods the crafted image and sends victim the link. Suggestion by @modus75 is good one to consider. <!-- github-comment-id:275641405 -->
Author
Owner

"<" is valid in filename on Linux :-/ One thing really nice on the upload form, compared to FTP synchronization, is that you have no constraint on filename.

@boogyman2 The current solution, using htmlentities before registering in database, prevents from stored XSS.

"<" is valid in filename on Linux :-/ One thing really nice on the upload form, compared to FTP synchronization, is that you have no constraint on filename. @boogyman2 The current solution, using htmlentities before registering in database, prevents from stored XSS. <!-- github-comment-id:275643922 -->
Author
Owner

@plegall okey pleg,am not much of a development guy,so i'll leave choice of choosing the better solution to you :) . Can you grab me a CVE for this?

@plegall okey pleg,am not much of a development guy,so i'll leave choice of choosing the better solution to you :) . Can you grab me a CVE for this? <!-- github-comment-id:275647103 -->
Author
Owner

Usually, the reporter gives us the CVE, not the opposite :-)

Usually, the reporter gives us the CVE, not the opposite :-) <!-- github-comment-id:275658161 -->
Author
Owner

Use the CVE Id , CVE-2017-5608

Use the CVE Id , CVE-2017-5608 <!-- github-comment-id:275979236 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#551