Converting Word to PDF without loading external resources


#1

Hello,
I would like to know how your conversion-engine actually converts a word file with resources linking to external resources (Like images), to a PDF.

I am working within an environment, where we would like to convert a word file to a pdf without risking exposing our self to load potential malicious software through external paths in word elemets, but still allow for the links to exist within the pdf. If the latter is not possible, it is also fine, but we want to make sure, we are not requesting potential malicious data.

I’ve been looking at the following topics, but I am not quite sure, how they handle external links:

https://apireference.aspose.com/net/words/aspose.words.loading/iresourceloadingcallback
https://docs.aspose.com/display/cellsjava/Control+loading+of+External+Resources+in+MS+Excel+Workbook+while+rendering+to+PDF

We are working with a 14.x version of your software, and it is not possible for us to update.

I hope I make myself clear, but if not, please do not hesitate to let me elaborate.

Best Regards
James Harrison


#2

@JaHarris,

What types of external links your Word documents may contain? Can you please ZIP and upload your sample Word document containing different scenarios of external links and attach it here for testing. We will then investigate the scenario on our end and provide you more information.


#3

I am not sure, it can potentially be any sort of link that word allows.

The issue is that it is our users who could potentially upload a malicious word file, and therefore, there is no specific type we want to exclude.

This guide below explains what we are a bit worried about:
https://blog.netspi.com/microsoft-word-unc-path-injection-image-linking/

This is a simple word file, with a link to an external python script (CTestOffUpload.zip (47.2 KB)
ould be something else)

Please let me know, if you need any more information.

Best Regards
James


#4

@JaHarris,

Please try using the following code. Hope, this helps:

LoadOptions opts = new LoadOptions();
opts.ResourceLoadingCallback = new HandleResourceLoadingCallback();
Document doc = new Document("E:\\temp\\TestOffUpload\\TestOffUpload.docx", opts);
doc.Save("E:\\temp\\TestOffUpload\\19.9.pdf");

class HandleResourceLoadingCallback : IResourceLoadingCallback
{
    public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
    {
        return (args.ResourceType != ResourceType.Document)
            ? ResourceLoadingAction.Skip
            : ResourceLoadingAction.Default;
    }
}

#5

Thank you very much. That would probably solve the issue.

Best Regards
James