Skip to content

Commit 1c9fc0e

Browse files
security: genericize internal-pattern regexes and document pickle trust boundary (#15)
- pattern-check.yml: replace an environment-specific registry hostname pattern with a generic, non-attributable '.corp' TLD pattern (broader coverage, no infrastructure naming disclosed). - AutoBayesModel.save/load: document that model.pkl is a pickle artifact and must only be loaded from trusted sources (CWE-502 guidance). - README: add a security note next to the artifacts list. No behavior change.
1 parent a2218f7 commit 1c9fc0e

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/pattern-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
'\.gluon/'
5252
'gluon-runner'
5353
'gluon-app\[bot\]'
54-
# Internal package registries
55-
'nexus\.alm\.europe\.cloudcenter\.corp'
54+
# Internal package registries / internal TLD suffixes (generic)
55+
'\.corp\b'
5656
'artifactory\.santander\.'
5757
# Internal IPv4 ranges (RFC1918)
5858
'\b10\.[0-9]+\.[0-9]+\.[0-9]+\b'

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ Training writes these files into `run.output_dir`:
244244
- `network.json`
245245
- `model.pkl`
246246

247+
> **Security note:** `model.pkl` is a Python
248+
> [pickle](https://docs.python.org/3/library/pickle.html) file. Loading a
249+
> pickle can execute arbitrary code, so call `AutoBayesModel.load()` only on
250+
> model directories you created yourself or obtained from a source you fully
251+
> trust.
252+
247253
## Limits
248254

249255
- Each table can have at most one parent relation.

src/auto_bayesian/model.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ def save(self, output_dir: str | Path) -> None:
148148
149149
Writes ``model.pkl``, ``metrics.json``, ``network.json``, and (when
150150
available) ``materialized.parquet`` into ``output_dir``.
151+
152+
.. note::
153+
``model.pkl`` is a :mod:`pickle` file. Treat saved model
154+
directories as trusted artifacts and share them only through
155+
channels where they cannot be tampered with.
151156
"""
152157
output_path = Path(output_dir)
153158
output_path.mkdir(parents=True, exist_ok=True)
@@ -208,7 +213,14 @@ def save(self, output_dir: str | Path) -> None:
208213

209214
@classmethod
210215
def load(cls, output_dir: str | Path) -> "AutoBayesModel":
211-
"""Load a model previously written by :meth:`save`."""
216+
"""Load a model previously written by :meth:`save`.
217+
218+
.. warning::
219+
``model.pkl`` is deserialized with :mod:`pickle`, which can
220+
execute arbitrary code embedded in a malicious file. Only load
221+
model directories that you created yourself or that come from a
222+
source you fully trust.
223+
"""
212224
output_path = Path(output_dir)
213225
with (output_path / "model.pkl").open("rb") as handle:
214226
payload = pickle.load(handle)

0 commit comments

Comments
 (0)