Skip to content

Commit e852204

Browse files
committed
Add security warning on loading untrusted data
1 parent fab9877 commit e852204

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

fints/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def get_data(self) -> bytes:
102102
@classmethod
103103
def from_data(cls, blob):
104104
"""Restore an object instance from a compressed datablob.
105+
`blob` **MUST NOT** be from an untrusted source.
105106
106107
Returns an instance of a concrete subclass."""
107108
version, data = decompress_datablob(DATA_BLOB_MAGIC_RETRY, blob)
@@ -334,6 +335,7 @@ def deconstruct(self, including_private: bool=False) -> bytes:
334335

335336
def set_data(self, blob: bytes):
336337
"""Restore a datablob created with deconstruct().
338+
`blob` **MUST NOT** be from an untrusted source.
337339
338340
You should only call this method once, and only immediately after constructing
339341
the object and before calling any other method or functionality (e.g. __enter__()).
@@ -1080,14 +1082,22 @@ def pause_dialog(self):
10801082
client.send_tan(...)
10811083
10821084
# Exiting the context here ends the dialog, unless frozen with pause_dialog() again.
1085+
1086+
**Warning:** `dialog_data` **MUST NOT** be stored in a place where an untrusted user could
1087+
modify it or you will have a major security issue.
10831088
"""
10841089
if not self._standing_dialog:
10851090
raise Exception("Cannot pause dialog, no standing dialog exists")
10861091
return self._standing_dialog.pause()
10871092

10881093
@contextmanager
10891094
def resume_dialog(self, dialog_data):
1090-
# FIXME document, test, NOTE NO UNTRUSTED SOURCES
1095+
"""
1096+
Create a dialog based on the data of a previous dialog.
1097+
1098+
**Warning:** `dialog_data` **MUST NOT** be from an untrusted source such as user-controlled
1099+
or client-side state or you will have a major security issue.
1100+
"""
10911101
if self._standing_dialog:
10921102
raise Exception("Cannot resume dialog, existing standing dialog")
10931103
self._standing_dialog = FinTSDialog.create_resume(self, dialog_data)

fints/dialog.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ def persistent_id(self, obj):
227227

228228
@classmethod
229229
def create_resume(cls, client, blob):
230+
"""
231+
`blob` **MUST NOT** be from an untrusted source.
232+
"""
230233
retval = cls(client=client)
231234
decompress_datablob(DATA_BLOB_MAGIC, blob, retval)
232235
return retval

fints/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def compress_datablob(magic: bytes, version: int, data: dict):
4343

4444

4545
def decompress_datablob(magic: bytes, blob: bytes, obj: object = None):
46+
"""
47+
`blob` **MUST NOT** be from an untrusted source.
48+
"""
4649
if not blob.startswith(magic):
4750
raise ValueError("Incorrect data blob")
4851
s = blob.split(b';', 3)

0 commit comments

Comments
 (0)