# Safety Download files

**URL:** https://discourse.julialang.org/t/safety-download-files/108233
**Category:** Web Stack
**Tags:** security, download
**Created:** [January 1, 2024, 5:32pm UTC](https://discourse.julialang.org/t/safety-download-files/108233 "2024-01-01T17:32:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![CeterisPartybus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ceterispartybus/32/46868_2.png) [@CeterisPartybus](https://discourse.julialang.org/u/CeterisPartybus)
#### Post date: [January 1, 2024, 5:32pm UTC](https://discourse.julialang.org/t/safety-download-files/108233/1 "2024-01-01T17:32:43Z")

</div>

This might be a stupid question as I am not a network/security guy.  
I am thinking about implementing a feature in a package I develop that downloads a file from an external server. Should safety be a concern here?

Specifically, I want to download a CSV file from a data repo using `Downloads.download()` and read it in afterwards. However, I worry that I accidentally implement a security risk. E.g. someone hacks the repo and exchanges the CSV file with a virus. Or someone resolves the URL to a different IP and makes the package download a virus from another server. Do I have to worry about these or similar scenarios and if yes: Could I mitigate the risk somehow?

Thanks!

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [January 1, 2024, 10:11pm UTC](https://discourse.julialang.org/t/safety-download-files/108233/2 "2024-01-01T22:11:02Z")

</div>

Compare the hash (e.g. sha256sum) of the downloaded file with the corresponding hash you know is good. The good hash can be hardcoded in your package. If the hash mismatch you simply error. This is a very common method and is used for example by the package manager.

---

<div class="post-metadata">

### Author: ![CeterisPartybus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ceterispartybus/32/46868_2.png) [@CeterisPartybus](https://discourse.julialang.org/u/CeterisPartybus)
#### Post date: [January 1, 2024, 10:22pm UTC](https://discourse.julialang.org/t/safety-download-files/108233/3 "2024-01-01T22:22:32Z")

</div>

Awesome, thanks for the tip. Can you recommend any resource to read into it a bit more?

---

<div class="post-metadata">

### Author: ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)
#### Post date: [January 2, 2024, 4:19pm UTC](https://discourse.julialang.org/t/safety-download-files/108233/4 "2024-01-02T16:19:41Z")

</div>

> **[File verification](https://en.wikipedia.org/wiki/File_verification)**
>
> File verification is the process of using an algorithm for verifying the integrity of a computer file, usually by checksum. This can be done by comparing two files bit-by-bit, but requires two copies of the same file, and may miss systematic corruptions which might occur to both files. A more popular approach is to generate a hash of the copied file and comparing that to the hash of the original file.
> File integrity can be compromised, usually referred to as the file becoming corrupted. A file ...
