Code Monkey home page Code Monkey logo

Comments (5)

mrbean-bremen avatar mrbean-bremen commented on June 16, 2024

Hm, how are SOP Instance UIDs in practice different from UUIDs? I may not understand the problem... do you think somebody will write a file path in the UID so the file will be saved in a sensible location, or something like that?

from pydicom.

scaramallion avatar scaramallion commented on June 16, 2024

Keep in mind I have very little knowledge of this, but you can do:

  1. Set the SOP Instance UID maliciously (ds.SOPInstanceUID = "/home/user/test.dcm")
  2. ???
  3. Profit - in my case, when I call FileSet.add(ds) I get the test.dcm file escaping the temporary directory and writing itself to my home directory.

When pydicom is setting the filenames using a random value, this is mitigated.

from pydicom.

scaramallion avatar scaramallion commented on June 16, 2024
from pydicom import dcmread
from pydicom.data import get_testdata_file
from pydicom.fileset import FileSet

fs = FileSet()
ds = dcmread(get_testdata_file("CT_small.dcm"))
ds.SOPInstanceUID = "/home/[user]/freeeeee.dcm"
fs.add(ds)

If you had a root level script running this could potentially be bad.

from pydicom.

mrbean-bremen avatar mrbean-bremen commented on June 16, 2024

Yeah ok, I guessed that you meant something like that. I'm also not an expert in security related stuff, so...
I think you are right and it makes sense to change this.

from pydicom.

darcymason avatar darcymason commented on June 16, 2024

I agree about it being a potential security issue, and am fine with the proposal, but thought of a possible alternative: what about just confirming UID is in fact a valid UID? Or more generally, confirm it has only digits and dots (and perhaps no ".." just to be extra safe).

However, this proposal does guarantee no conflicting values, and no security risk at all, so if it can work without too much added complexity, I'm good with that.

from pydicom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.