From b3eb3b00d0e68f1ef46168fdc5bb5fb6c4ed4c65 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 13 Jul 2026 19:16:46 -0700 Subject: [PATCH 1/3] fix(pii): bump transformers to 5.5.0 for LightGlue RCE advisory transformers <5.5.0 is vulnerable to arbitrary code execution during model initialization in the LightGlue loading path (Dependabot alerts #174/#175). huggingface_hub moves 1.3.0 -> 1.23.0 because transformers 5.5.0 requires huggingface-hub>=1.5.0. Verified the full pin set (torch 2.11.0, gliner 0.2.27, presidio 2.2.362, spacy 3.8.14) resolves with pip; gliner 0.2.27 allows transformers <5.7.0 and any hub >=0.21.4. --- apps/pii/requirements-gliner.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/pii/requirements-gliner.txt b/apps/pii/requirements-gliner.txt index a3d002f3850..1fa34dd7c07 100644 --- a/apps/pii/requirements-gliner.txt +++ b/apps/pii/requirements-gliner.txt @@ -6,5 +6,5 @@ # torch is pinned in the Dockerfile instead: the CPU and CUDA targets install # the same version from different wheel indexes. gliner==0.2.27 -transformers==5.3.0 -huggingface_hub==1.3.0 +transformers==5.5.0 +huggingface_hub==1.23.0 From e6884fa62ca06042eee24f13c42e26a7bcdb5bd4 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 13 Jul 2026 19:25:29 -0700 Subject: [PATCH 2/3] improvement(pii): assert real GLiNER inference in the image build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bake step previously only proved GLiNER.from_pretrained loads — a transformers/gliner bump that silently stops returning detections would still build and pass /health. The bake step now runs predict_entities on a sample sentence (labels from engines.py's GLINER_ENTITY_MAPPING) and fails the build unless person + location are detected. Verified against the exact bumped pin set (transformers 5.5.0, huggingface_hub 1.23.0, gliner 0.2.27, torch 2.11.0): person 0.9999, location 0.9951, date 0.9987. --- docker/pii.Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/pii.Dockerfile b/docker/pii.Dockerfile index 205462bad3f..7388c58e80f 100644 --- a/docker/pii.Dockerfile +++ b/docker/pii.Dockerfile @@ -87,9 +87,16 @@ RUN --mount=type=cache,target=/root/.cache/pip \ # Bake the GLiNER weights at build time (cached layer) so startup never # touches the network. HF_HUB_OFFLINE makes a missing/overridden # PII_GLINER_MODEL fail fast at startup instead of silently downloading. +# The predict_entities smoke assert (labels from engines.py's +# GLINER_ENTITY_MAPPING) fails the build if a transformers/gliner bump loads +# the model fine but silently stops returning detections. ENV HF_HOME=/opt/hf-cache ARG GLINER_MODEL=urchade/gliner_multi_pii-v1 -RUN python -c "from gliner import GLiNER; GLiNER.from_pretrained('${GLINER_MODEL}')" && \ +RUN python -c "from gliner import GLiNER; \ +model = GLiNER.from_pretrained('${GLINER_MODEL}'); \ +ents = model.predict_entities('John Smith flew to Paris on 4 May 2021.', ['person', 'location', 'date']); \ +labels = {e['label'] for e in ents}; \ +assert {'person', 'location'} <= labels, f'GLiNER smoke inference failed, got: {ents}'" && \ chmod -R a+rX /opt/hf-cache ENV HF_HUB_OFFLINE=1 From 6dd8465a23fe2ddcb663c42703b9759996c3ef18 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 13 Jul 2026 19:34:50 -0700 Subject: [PATCH 3/3] improvement(pii): require date detection in the GLiNER build smoke assert The smoke input already requests the date label; asserting it closes the gap where DATE_TIME detection could silently regress while person and location still pass. Verified locally against the bumped pin set: all three labels detected. --- docker/pii.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/pii.Dockerfile b/docker/pii.Dockerfile index 7388c58e80f..66a32757af7 100644 --- a/docker/pii.Dockerfile +++ b/docker/pii.Dockerfile @@ -96,7 +96,7 @@ RUN python -c "from gliner import GLiNER; \ model = GLiNER.from_pretrained('${GLINER_MODEL}'); \ ents = model.predict_entities('John Smith flew to Paris on 4 May 2021.', ['person', 'location', 'date']); \ labels = {e['label'] for e in ents}; \ -assert {'person', 'location'} <= labels, f'GLiNER smoke inference failed, got: {ents}'" && \ +assert {'person', 'location', 'date'} <= labels, f'GLiNER smoke inference failed, got: {ents}'" && \ chmod -R a+rX /opt/hf-cache ENV HF_HUB_OFFLINE=1