Skip to content

Conversation

@Girgias
Copy link
Member

@Girgias Girgias commented Jan 26, 2025

No description provided.

@Girgias Girgias requested a review from nielsdos January 26, 2025 05:41
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

Interesting find!

PDO_STMT_CLEAR_ERR();
/* Increase refcount for ctor_args as those might be removed during individual fetches */
bool increase_refcount_ctor = Z_TYPE(stmt->fetch.cls.ctor_args) == IS_ARRAY;
if (increase_refcount_ctor) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's better to combine this with the ZVAL_COPY_VALUE, i.e. make that ZVAL_COPY. However, this is not hugely important (it also depends on how this would complicate the resolution of my second comment).

}

do_fetch_opt_finish(stmt, 0);
if (increase_refcount_ctor) {
Copy link
Member

Choose a reason for hiding this comment

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

I suppose it's theoretically possible that the ctor_args is changed by user code during the do_fetch operation.
In that case we may be destroying the wrong instance.
So I think you should keep a pointer to the HashTable that you initially refcount-incremented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually this seems like a more sensible approach, and more general let me try some new test cases and this idea.

@Girgias Girgias force-pushed the pdo-uaf-set-fetch-mode-stuffing branch from ffa55b3 to e124848 Compare January 26, 2025 14:04

do_fetch_opt_finish(stmt, 0);
if (current_ctor) {
// TODO: can current_ctor contain cycles? If yes, then this should be added as possible root (or be handled via a zval*)
Copy link
Member

Choose a reason for hiding this comment

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

This TODO should be removed upon squash-merging.

@Girgias
Copy link
Member Author

Girgias commented Jan 26, 2025

Merged as 3027600

@Girgias Girgias closed this Jan 26, 2025
@Girgias Girgias deleted the pdo-uaf-set-fetch-mode-stuffing branch January 26, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants