News for hackers. Stuff that matters.
Re:URL to PDF Microservice by erdbeerkaese on Thursday October 05, 2017 @10:48AM (#15409590)
Unfortunately, the "sensible defaults" don't seem to check input URLs correctly and allow file:// URLs.

Just try ?url=file:///etc/passwd on the demo instance.

That seems to be a quite common issue with services like this built on generic libraries.

Re:URL to PDF Microservice by kimmobru on Thursday October 05, 2017 @11:22AM (#15409893)
Oh wow, that's a bit embarrassing :) The urls are now restricted to http and https only. Thanks for noticing!
Re:URL to PDF Microservice by qw on Thursday October 05, 2017 @01:46PM (#15411016)
I am not at a computer noe, so I can’t test it, but do you take redirects into account? I hope you are not just whitelisting the initial URL, but also any URL’s it redirects to. If you don’t already, you should probably just disable redirects in whatever library you use.
Re:URL to PDF Microservice by kimmobru on Thursday October 05, 2017 @04:21PM (#15412295)
I gave this a thought for a moment. Since we're using a real browser, there are huge amount of different ways to get the browser display a file:// link. Redirect is one, window.location.href is another, etc. The service shouldn't be run publicly in the internet for real use cases. If you do, the server should be designed in a way that it's not dangerous if the web server user gets read access to file system. I added a warning about this in the top of the README.
Re:URL to PDF Microservice by cutcss on Thursday October 05, 2017 @05:03PM (#15412572)
You are using Chrome headless therefore you can use group policy to add "file://" to the URL blacklist; see http://www.chromium.org/administrators/policy-list-3#URLBlac...
Re:URL to PDF Microservice by jotto on Thursday October 05, 2017 @06:27PM (#15413037)
By default: if Headless Chrome hits a redirect to a file:// it returns: net::ERR_UNSAFE_REDIRECT

window.location.href = 'file:///' will return console error: "Not allowed to load local resource"

Re:URL to PDF Microservice by kbenson on Thursday October 05, 2017 @07:43PM (#15413430)
This is ripe for an easter egg if you request a file:// URL PDFs support compression, right? I wonder how hardened they are to zip bombs...
Re:URL to PDF Microservice by rocky1138 on Thursday October 05, 2017 @12:50PM (#15410629)
Consider adding FTP.

It might be better to blacklist file:// rather than trying to have a comprehensive whitelist.

Re:URL to PDF Microservice by nothrabannosir on Thursday October 05, 2017 @12:54PM (#15410649)
Not sure if this is sound advice. Blacklisting is a cat and mouse game, especially for security. The risk of a missing entry on a blacklist is worse than on a whitelist.
Re:URL to PDF Microservice by homero on Thursday October 05, 2017 @11:03AM (#15409715)
I've moved all my pdf to client side. Less security and processing on the server.

http://pdfmake.org/#/gettingstarted

Re:URL to PDF Microservice by dotmanish on Thursday October 05, 2017 @12:36PM (#15410514)
Interesting. There's jsPDF as well which is similar: https://github.com/MrRio/jsPDF
Re:URL to PDF Microservice by leesalminen on Thursday October 05, 2017 @01:39PM (#15410959)
Does anyone have advice on rendering wide tables (with lots of text) with this library? We have a constant cat ant mouse game with this library.
Re:URL to PDF Microservice by welder on Thursday October 05, 2017 @08:35PM (#15413633)
Then you can't send pdfs in emails or pre-cache pdfs...
Re:URL to PDF Microservice by welder on Friday October 06, 2017 @12:55PM (#15418288)
On second thought, if you're ok with linking to PDFs instead of attaching them in emails then you can pre-cache all content needed to generate PDFs. Besides email attachments, I can't think of a use-case for server side generating PDFs.
Re:URL to PDF Microservice by adrianpike on Thursday October 05, 2017 @12:19PM (#15410367)
Is there a browser support matrix somewhere? This looks real promising but we need to support IE9. :(
Re:URL to PDF Microservice by woebtz on Thursday October 05, 2017 @02:06PM (#15411225)
Also consider non-Western languages (CJK, Russian, Arabic). My team got bit by this when we discovered we couldn't render emoji's client-side.
Re:URL to PDF Microservice by katastic on Thursday October 05, 2017 @04:15PM (#15412250)
That didn't work for me. Was it patched already?

    {"status":400,"statusText":"Bad Request","errors":[{"field":["url"],"location":"query","messages":["\"url\" must be a valid uri with a scheme matching the http|https pattern"],"types":["string.uriCustomScheme"]}]}