Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent recursions from crashing stack #40

Merged
merged 1 commit into from
Jun 15, 2022
Merged

Prevent recursions from crashing stack #40

merged 1 commit into from
Jun 15, 2022

Conversation

Tampa
Copy link
Contributor

@Tampa Tampa commented Jun 15, 2022

This is a bandaid more than a true fix, but without preventing recursions from running wild the process will eventually exceed stack and crash. This was reported as being an issue with loading restricted pages while not logged in to wifi. The actual issue is thus elsewhere in the page handling. Nonetheless recursions should be avoided if they have no bail condition that turns true before hitting stack limits. Please fix the page handling for this and perhaps rethink the approach of using recursions for parsing the pages in the first place.

This is a bandaid more than a true fix, but without preventing recursions from running wild the process will eventually exceed stack and crash. This was reported as being an issue with loading restricted pages while not logged in to wifi. The actual issue is thus elsewhere in the page handling. Nonetheless recursions should be avoided if they have no bail condition that turns true before hitting stack limits. Please fix the page handling for this and perhaps rethink the approach of using recursions for parsing the pages in the first place.
@Outworldz
Copy link

POST attacks may still work with this patch as there will be content. See #39

@Tampa
Copy link
Contributor Author

Tampa commented Jun 15, 2022

This pr is not to fix that issue, but to prevent recursions from rogue content being infinitely parsed. #39 describes a problem that happens as part of creating a new processing object for each of them. The problem is the entire design of this system being prone to recursions and stack overflows, it should be revised completely to avoid recursive code paths.

@Outworldz
Copy link

Both do essentially the same thing so nothing is very different. But thanks for making a patch!

@Tampa
Copy link
Contributor Author

Tampa commented Jun 15, 2022

They are not the same thing. The attack vector isn't in estate handling or post requests on this. I'm not going to discuss the specifics here as this is a security patch and as stated the entire system needs rewriting to prevent the recursions of the various code paths from causing crashes, which will inevitably include the issue described in #39 as well.

@Outworldz
Copy link

if (recursions > 10)
return string.Empty;
works the the same as
if (m_Index> 10)
return string.Empty;
But in fewer conditions.
But that would be arguing over minor details.

@diva diva merged commit 9b32af9 into diva:master Jun 15, 2022
@diva
Copy link
Owner

diva commented Jun 15, 2022

Thanks. This will do for now.

@aiaustin
Copy link

aiaustin commented Jun 16, 2022

I installed the patch for Processor.cs. Thanks. But I see an issue in the Wifi interface when, for example, using "Manage Accounts" when logged on as the grid owner. The usual single space search does not show all users... only 11 show. I assume that's the recursion limit (+1) which causes the problem.

I simply set the recursion limit set in the patch higher temporarily.

Just while looking at this, is there a real reason to limit searches there to a min of 3 characters? Would 2 be more reasonable and work fine for smaller grids anyway?

@Outworldz
Copy link

500 On windows does not run out of stack space. But it limites the Avatars list to 500 users.

@Tampa
Copy link
Contributor Author

Tampa commented Jun 25, 2022

Again, this is a bandaid, temporary, preventing the worst cases. The actual fix for this is code that doesn't rely on recursion to parse data and has clear conditions on what it parses and what is discarded to prevent things from running away. That's something @diva needs to look into as I don't have a full overview of the code or data it works with.

I suspect or at least hope that redesign of this function or the larger content serving system is in the works and will be merged soon.

@aiaustin The reason search is limited is because most names contain more than 3 letters and the quantity of results grows exponentially from 3 to 2 characters.

@Outworldz
Copy link

Outworldz commented Jun 26, 2022

Edited: Depending on the patch, its limited N lines (10) which is very little, and certainly not enough. A JSON response to a Ajax call and a javascript table with search and paging would be what I would do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants