What is an Outlook SafeLink and why decode it?
When Microsoft Defender for Office 365 has Safe Links turned on, every link in an incoming email is rewritten. The address you see when you hover has nothing to do with the page the sender meant: it starts with something like https://nam12.safelinks.protection.outlook.com/?url= and carries the real address, percent-encoded, in the url parameter, plus extra tracking data. Clicking sends you through Microsoft's servers first, which check the destination, and then forward you to the original page.
The rewritten link is long, ugly and awkward to reuse. If you copy it into a ticket, a document or a chat, you paste a tracking address tied to one recipient and one moment. If you want to know where a link really goes before you click, you have to read it. Decoding gives you back the original URL so you can paste it in a ticket, compare it with what the sender said, or check the domain against a phishing report.
This decoder reads four Microsoft hosts (the global one and its US government and China variants) and also Proofpoint URL Defense links, the same idea from another vendor, in its v2 form and in the v3 form when no characters were substituted. If a mail was forwarded and the link got wrapped twice, it keeps unwrapping and tells you how many layers it removed. All the work happens in your browser: the link you paste is parsed locally, and the page behind it is never opened.
How to decode a SafeLink
- In the email, copy the link address: right-click the link and choose the copy-link option, or long-press on a phone. Do not click it.
- Paste the whole link in the input box. The page opens with an example already filled in, so you can see how the result looks; clear it with the clear button in the field.
- The original URL appears in the result box as soon as the text is valid. There is no button to press.
- If the link was wrapped more than once, a note below the result says how many times and that every wrapper was removed.
- Copy the result with the copy button of the box and use it where you need it.
Decoding is not an approval. A decoded link can still lead to a harmful page, so read the domain carefully before you open it. To see the pieces of the address one by one (host, path, query), paste the result in the URL parser. To turn a long query value back into readable text, the URL decoder does the percent-decoding by hand.
Examples
A basic Outlook SafeLink
Input:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fexample.com%2Fpage%3Fa%3D1&data=05%7C01Output:
https://example.com/page?a=1The data part is tracking information and is dropped.
A link copied from the HTML source, with &
Some mail clients and exports escape the ampersand. Both forms work:
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fexample.com%2Freport%3Fid%3D7%26lang%3Dpt&data=05%7C01%7Cana%40empresa.com&sdata=abc&reserved=0Output, with the query of the original link intact (id=7&lang=pt):
https://example.com/report?id=7&lang=ptA Proofpoint URL Defense v2 link
In v2 the original address is in u, with - standing for % and _ for /:
https://urldefense.com/v2/url?u=https-3A__example.com_docs_file-2Dname.pdf&d=DwMFaQ&c=abcOutput:
https://example.com/docs/file-name.pdfA link wrapped twice
A forwarded email can wrap an already wrapped link. The tool unwraps both and reports two layers:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fnam12.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fexample.org%252Fx%253Fy%253D1Output:
https://example.org/x?y=1Common errors and how to fix them
- This is not a valid URL: the text is not a complete address. Paste the whole link, beginning with
https://, without line breaks or quotes around it. - This is not a SafeLink: the host is neither a Microsoft Safe Links host nor
urldefense.com. A normal link, or one rewritten by another security product, cannot be decoded here. - This link has no url= (or u=) parameter: the link was cut when copied. Go back to the email and copy it again in full; long links are easy to truncate.
- A Proofpoint v3 link with
*in the address: v3 replaces some characters with*and lists them in an encoded block at the end. Those links are not decoded here, and the page says so instead of showing a wrong address. Use the decoder offered by Proofpoint for them.
Frequently asked questions
How do I remove the safelinks.protection.outlook.com part of a link?
Paste the link above. The tool takes the value of the url parameter, which is the original address, and shows it. You can also do it by hand: copy what comes after url= up to the next & and decode the percent signs.
Is it safe to decode a SafeLink?
Decoding is only reading text. The tool does not open the link or contact the destination, and the work is done in your browser. What you do with the decoded address afterwards is another matter, so check the domain before you visit it.
Why does Outlook rewrite my links?
It is a protection feature of Microsoft Defender for Office 365 (Safe Links). The link is checked at the moment you click, so a page that turns malicious after delivery can still be blocked. Other products, such as Proofpoint, do the same.
Can I get the real URL from a link I already clicked?
Yes, as long as you still have the rewritten address, for example in the browser history or the mail. Paste it here.
What does the layers note mean?
It means the link was rewritten more than once, which happens when an email is forwarded between organisations that all use link protection. All wrappers are removed.
Does it also decode Proofpoint links?
Yes, urldefense.com v2 links and v3 links without substituted characters. See the errors above for the v3 exception.
How to decode a SafeLink in code
JavaScript
URLSearchParams already percent-decodes the value.
const link = 'https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fexample.com%2Freport%3Fid%3D7%26lang%3Dpt&data=05%7C01&reserved=0';
console.log(new URL(link).searchParams.get('url')); // https://example.com/report?id=7&lang=ptPython
from urllib.parse import urlparse, parse_qs
link = "https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fexample.com%2Freport%3Fid%3D7%26lang%3Dpt&data=05%7C01&reserved=0"
print(parse_qs(urlparse(link).query)["url"][0]) # https://example.com/report?id=7&lang=ptGo
u, err := url.Parse(link)
if err != nil {
panic(err)
}
fmt.Println(u.Query().Get("url"))