Skip to content

Fix use-after-free in creature conditions#4726

Merged
EvilHero90 merged 1 commit intootland:masterfrom
diath:conditionsuaf
Jun 4, 2024
Merged

Fix use-after-free in creature conditions#4726
EvilHero90 merged 1 commit intootland:masterfrom
diath:conditionsuaf

Conversation

@diath
Copy link
Copy Markdown
Contributor

@diath diath commented Jun 3, 2024

The Creature class destructor loops over the conditions member variable and calls condition->endCondition then deletes the condition object, however, ConditionInvisible::endCondition calls Creature::isInvisible, which subsequently loops over the conditions (which are not erased when being deleted in the destructor), calling condition->getType on an already deleted memory, resulting in UAF. This fixes the issue by first ending all conditions, then deleting them separately (as erasing the elements one-by-one in the Creature destructor does not make much sense).

@EvilHero90 EvilHero90 added enhancement Increase or improvement in quality, value, or extent bugfix labels Jun 3, 2024
@EvilHero90 EvilHero90 added this to the 1.6 milestone Jun 3, 2024
@ghost ghost requested review from DSpeichert, MillhioreBT, nekiro and ranisalt June 4, 2024 05:00
Copy link
Copy Markdown
Member

@ranisalt ranisalt left a comment

Choose a reason for hiding this comment

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

Good catch. It is probably better to use smart pointers here, but this is a good stop-gap.

@EvilHero90 EvilHero90 merged commit 3d7c2fe into otland:master Jun 4, 2024
csantbr pushed a commit to csantbr/forgottenserver-downgrades that referenced this pull request Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix enhancement Increase or improvement in quality, value, or extent

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants