Project

General

Profile

Actions

Bug #22638

closed

Out-of-bounds read via stale MatchData char-offset cache

Bug #22638: Out-of-bounds read via stale MatchData char-offset cache

Added by byroot (Jean Boussier) 1 day ago. Updated 1 day ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:127717]

Description

input = "abcdefgh"
big = /(.)(.)(.)(.)(.)(.)(.)(.)/
small = /(.)/
big =~ input
input.split(small, 2) { |s| Regexp.last_match.offset(1) if s.length == 1 }
m = big.match(input)
p (0..8).map { |i| m.offset(i) }

Expected::

[[0, 8], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]

Actual:

[[0, 1], [0, 1], [0, 33], [15180044, 281473212212120], [0, 65], [4294967298, 281473667944640], [281473211869520, 17179869185], [4, 187651108004256], [0, 337]]

Reported by: ProofHunt (https://hackerone.com/proofhunt)

Actions

Also available in: PDF Atom