Skip to content

Fix security issues - #3489

Merged
jeromekelleher merged 5 commits into
tskit-dev:mainfrom
jeromekelleher:fix-security-issues
Oct 20, 2026
Merged

jeromekelleher merged 5 commits into
tskit-dev:mainfrom
jeromekelleher:fix-security-issues

Conversation

@jeromekelleher

Copy link
Copy Markdown
Member

Fixes a handful of security issues reported by @gregorgorjanc - Codex was spot on.

I'm quite pleased that this is all that security audits are surfacing - go tskit!

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.68%. Comparing base (2839a12) to head (0570380).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3489      +/-   ##
==========================================
- Coverage   91.68%   91.68%   -0.01%     
==========================================
  Files          38       38              
  Lines       32233    32241       +8     
  Branches     5153     5155       +2     
==========================================
+ Hits        29554    29559       +5     
  Misses       2346     2346              
- Partials      333      336       +3     
Flag Coverage Δ
C 82.26% <100.00%> (+0.02%) ⬆️
c-python 77.52% <93.75%> (-0.04%) ⬇️
python-tests 96.44% <ø> (ø)
python-tests-no-jit 33.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Python API 98.73% <ø> (ø)
Python C interface 91.25% <ø> (ø)
C library 91.22% <100.00%> (-0.02%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeromekelleher

Copy link
Copy Markdown
Member Author

Also tacked on a couple of extra fixes which came up while looking at this.

@hyanwong

Copy link
Copy Markdown
Member

I am diving a little into the C code at the moment, and the changes here all LGTM. In particular, in the C code I was able to figure out what the (minor) changes fixed before reading the summaries. But I guess someone else with better knowledge of the C code should formally approve.

@petrelharp petrelharp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@petrelharp

Copy link
Copy Markdown
Contributor

But, looks like we've dropped coverage for something?
Screenshot From 2026-10-19 08-49-26

@jeromekelleher

Copy link
Copy Markdown
Member Author

Ah, whoops! Thanks, I'll look into this

Sample and ancestor IDs equal to the number of nodes were accepted,
leading to out-of-bounds accesses on node-sized arrays.

Closes tskit-dev#3484
Sample IDs equal to the number of nodes were accepted by both
ibd_within and ibd_between, leading to an out-of-bounds write
on the sample_set_id array.

Closes tskit-dev#3485

Add link_ancestors test skipping an internal node

Restores coverage of the non-merging append in ancestor_mapper_add_ancestry,
previously only reached by a Python test that relied on an out-of-bounds
ancestor ID.
delete_older used edge parents, mutation nodes and mutation parents
as array indexes without validation, after it had already started
rewriting the tables. Invalid references led to out-of-bounds reads
and partially modified tables.

Closes tskit-dev#3486
The table metadata schema tests computed the length of example2
using strlen(example), reading past the end of the shorter string.
test_zero_edges passed a single tsk_id_t as the simplify node_map,
which must have space for every input node.
The number of reference sets was used to compute an allocation size
before being checked, so out-of-range values led to very large (or
overflowing) allocation requests before the error was returned.
@jeromekelleher

Copy link
Copy Markdown
Member Author

Great catch @petrelharp - turns out one of the old tests was using an out-of-bounds node to test this code path. Added a new test to do it properly.

@jeromekelleher
jeromekelleher added this pull request to the merge queue Oct 20, 2026
Merged via the queue into tskit-dev:main with commit 49eff38 Oct 20, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants