mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 06:06:09 -06:00
[GH-ISSUE #491] Stack Buffer Overflow in lxw_datetime_to_excel_datetime() with Invalid Month Values #384
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#384
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 (Oct 11, 2025).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/491
Originally assigned to: @jmcnamara on GitHub.
Description
A stack buffer overflow vulnerability exists in libxlsxwriter's datetime conversion function. When
lxw_datetime_to_excel_datetime()is called with amonthvalue greater than 12, the function accesses beyond the bounds of themdaysarray, causing a stack buffer overflow.Steps to Reproduce
Environment
Compilation Command
Minimal Test Case
Expected Behavior
The library should:
monthis in the range 1-12Actual Behavior
The program crashes with a stack buffer overflow:
Root Cause
In
src/utility.cfunctionlxw_datetime_to_excel_date_with_epoch(), line 411:The function reads
datetime->monthfrom user input but does not validate it before using it as a loop bound to access themdaysarray. Whenmonth > 12, the loop accesses beyond the array bounds.Call Stack
Proposed Fix
Add input validation at the start of
lxw_datetime_to_excel_date_with_epoch():Additional Information
This bug is detected by fuzzing.
@jmcnamara commented on GitHub (Oct 13, 2025):
Thanks. I'll look into that.
@jmcnamara commented on GitHub (Oct 31, 2025):
Fixed on main. Thanks.