In-app reader
Component.__eq__ compares subcomponents in O(2^n) time relative to nesting depth. Because the parser accepts arbitrarily nested components, a sub-kilobyte .ics file is enough to make a single equality check run for minutes or hang indefinitely. Any application that compares parsed components (==, !=, in, set/dict membership, deduplication, test assertions) against attacker-supplied calendar data is exposed to denial of service.
Component subclasses dict and stores children in a separate subcomponents list. __eq__ (src/icalendar/cal/component.py:642-665) checks set-equivalence of children with two membership loops:
def __eq__(self, other):
if len(self.subcomponents) != len(other.subcomponents):
return False
if not super().__eq__(other):
return False
for subcomponent in self.subcomponents:
if subcomponent not in other.subcomponents:
return False
for subcomponent in other.subcomponents:
if subcomponent not in self.subcomponents:
return False
return True
Discussion
Sign in to join the discussion.
Keep reading
Optional: create a free account to save items, track programs, and sync across web + app. Reading stays free.