0

A thought experiment

My goal is to know whether, and how, a 3rd party python script that may be entrusted with sensitive information, can be trusted on a fundamental level.

Basically this question is, can a Python script communicate with a 3rd party without importing one of a set of core modules to facilitate a communication?

I ask this in the context of reviewing a script that converts a password database. https://github.com/asfaltboy/csv2keepass

And at time of writing, the script only imports:

import argparse
import csv
import datetime
import logging
import operator  # Toolkit
import re
import sys
import xml.etree.ElementTree as ET  # Saves data, easier to type

I do not think there are any dynamic imports in this case; Dynamic imports would sew implicit distrust with me due to complexity.

I know the sys module can touch a couple specific streams.

Given a set of known imports, really a dependency chain; Can it be ruled that a given script is fundamentally incapable of exposing sensitive data? Due to its lack of importing native code to facilitate said transport?


Consideration; the open (or file alias) calls are available in all script, since its a core datatype; And due to the flexibility of unix files, should any calls to open/file be considered an attack surface?

1

You simply can not assume a program or script is safe solely on their imports. It is to easy to either combine functions or to abuse some 'safe' feature to do something unexpected (like using time queries to transmit data to a command and control server, or tricking the system to running curl with a payload of your data)

The only way to know is to do a proper code review of the script and than evaluate if a script is 'safe' or not (safe being what you define as save to use) there are no High risk imports being added to the script in your post, but you would also have to check for bash / system / eval commands that 'break out' of the python environment

  • 2
    It also depends on what level of "safe" you're going for. If you're only worried about network traffic, that's one thing. But if you're worried about libraries leaving traces of your data in memory, being vulnerable to timing attacks, etc, then that's a whole different game. – Mike Ounsworth May 13 '15 at 1:15
  • @MikeOunsworth ahh your comment make it obvious that if I am only worried about network traffic I can be confident by processing on an offline machine. – ThorSummoner May 15 '15 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.