mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #486] NULL Pointer Dereference in libxlsxwriter Chart Processing #380
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#380
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LkkkLxy on GitHub (Sep 29, 2025).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/486
Originally assigned to: @jmcnamara on GitHub.
Describe the bug
A NULL pointer dereference vulnerability exists in libxlsxwriter's chart processing workflow. The issue stems from inadequate input validation in
workbook_add_chart()which accepts invalid chart types, leading to incomplete initialization of chart structures. Whenworkbook_close()attempts to process these malformed charts, a NULL pointer dereference occurs in_write_chart_files().Root Cause Analysis
Technical Details
workbook_add_chart(workbook, 0)accepts invalid chart type0_chart_initialize()only prints a warning for invalid types but doesn't initialize critical function pointers_write_chart_files()callslxw_chart_assemble_xml_file()which attempts to call NULL function pointersCall Chain
To Reproduce
Ultra-minimal reproduction code (6 APIs, tested and verified):
Compilation and Testing
Expected behavior
The library should:
Version
Additional Context
This bug was discovered through fuzz testing.
By examining the code, I believe that since LXW_CHART_NONE is defined in the enum, it is inappropriate to leave it unhandled. This does not fall under API misuse. It can be addressed simply with an if check, or even with an assert. (Of course, for values outside the range of the enum provided to users, we don’t need to handle them — that would be API misuse.)
Of course, there are other higher-cost approaches, but I don’t think it is appropriate to introduce significant overhead for such a minor bug. Since I am a fuzz tester and lack prior knowledge of this library, my proposed solution may not be entirely accurate. If you have other ideas, I’d be happy to discuss them.
@jmcnamara commented on GitHub (Sep 29, 2025):
Thanks for the detailed report. I'll look into it.
@jmcnamara commented on GitHub (Sep 29, 2025):
Fixed on main. Thanks for the report.