-
Notifications
You must be signed in to change notification settings - Fork 30
MIME sniffing could be potentially dangerous on the gateway #222
Comments
very much agreed. Ideally the MIME can be on the unixfs file and read from there |
yeah exactly |
Probably MIME should then also be part of metadata which gets hashed together with content. So the same content but different MIME would be a different address. |
@mitar saving the data with MIME in the metadata and does giving it a new hash will lead to unnecessary overhead for the same data with different MIME headers. That is: a node will have to save multiple copies of the same data just to serve the different MIME headers of the file. It is cheaper not to put the MIME header as part of the hash. Does a node will have to save only one set of data but be able to serve it for files with different MIME headers. |
@raslyon? What? First, why would you serve the same data as multiple MIME types I do not understand. What would be the use case here? But in any case, IPFS is build around DAGs, content blocks can be separate from metadata data, so there is no reason why content would have to be stored as multiple copies. To really address your use case, I think the best solution is that you can also store the file using metadata which lists all potential MIME types under which the file can be served. Again, the issue is not that a file should not have different MIME types, but that we should not try to be smart and guess the MIME type, especially not in a way that it is not controllable. (So better to guess it add adding time, then serving time.) |
@mitar thanks i now understand your point. I think my former understanding of your point was incorrect. |
Web history is full of security issues when browsers did MIME sniffing to "fix" broken MIME types returning by servers.
Now if seems that IPFS is doing the same. I think this is very problematic if we want to host whole web applications on top of IPFS. I think there should be a way to at least set a fixed MIME type, or even add headers like
X-Content-Type-Options: nosniff
.One other option could be that MIME type would be resolved at the adding the file to the IPFS. Not at the gateway sending time. So user could check and verify what is the MIME type detected, and then override that if necessary.
See also:
The text was updated successfully, but these errors were encountered: