External resources refer to various types of content or files that are not directly embedded within the document but are instead referenced and loaded from external locations. These resources enhance the functionality, appearance, and interactivity of the document. Common external resources include images, audio, video, fonts, CSS, scripts, frameworks, and so on. GroupDocs.Conversion considers external any resource that a document is trying to load from an external URL.
Utilizing external resources optimizes the performance, maintainability, and scalability of web pages and other documents. These resources are typically cached by browsers, which can reduce the load time of subsequent visits to a website. However, relying too heavily on external resources can also introduce dependencies and potential points of failure if the external sources become unavailable.
Security considerations
Loading external resources from untrusted documents can pose security risks:
Server-Side Request Forgery (SSRF): A malicious document could contain references to internal network resources, potentially allowing attackers to probe or access internal services.
NTLM credential leaks: Documents with UNC paths (e.g., \\server\share) could trigger automatic NTLM authentication, potentially leaking credentials.
Data exfiltration: External resources could be used to track document access or exfiltrate data.
To mitigate these risks, GroupDocs.Conversion implements a secure by default approach - the SkipExternalResources property is set to true by default in all supporting load options classes.
Supported document types
The external resource loading control is available for the following document types:
All these classes implement the IResourceLoadingOptions interface, which defines the SkipExternalResources and WhitelistedResources properties.
Restricting external resources
By default, SkipExternalResources is set to true, which means external resources are already blocked. If you have previously enabled external resource loading and want to restrict it again, set the SkipExternalResources property to true.
The following code snippets show how to skip loading of external resources for different document types:
Sometimes you may want to skip loading most of the external resources, but still load some particular resources from trusted sources.
To allow-list specific resources during the conversion, use the WhitelistedResources property. This property accepts a list of strings containing portions of URLs to be allowed. The WhitelistedResources property is effective only when the SkipExternalResources property is set to true.
The following code snippet shows how to load JPG and JPEG images and any resources from the example.com domain while restricting all other external resources: