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

Implements front end refresh button #257

Merged
merged 4 commits into from
Oct 12, 2017
Merged

Conversation

joaquimds
Copy link
Contributor

Adds an /update action that runs the update command with the provided "name" parameter. Updates are limited by IP to 10 per hour.

Please check for security holes as we are dealing with client input!

@joaquimds joaquimds requested review from tamlyn and khromov October 11, 2017 15:18
web/index.php Outdated

$input = new ArrayInput(array(
'command' => 'update',
'--name' => $name
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe match against the slug in the DB first using a prepared statement? And then if slug exists run the command on the returned slug rather than the user input. I'm not sure it's safe to just pass the name here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I've done that now

@khromov
Copy link
Collaborator

khromov commented Oct 11, 2017

My general comment is that this is an OK approach. I wonder if we could make a simpler check by just looking at last_fetched and only allowing one fetch every hour or so per plugin. That would be slightly more abuse-friendly but would save some code. Just a thought, like I said the proposed solution is fine as well!

@joaquimds
Copy link
Contributor Author

I think using the last_fetched wouldn't be quite right, as there are so many plugins it'd still be quite easy for an attacker to overload the server.

The code could do with a tidy, that's for sure, but I just haven't got the time.

@khromov
Copy link
Collaborator

khromov commented Oct 11, 2017

@joaquimds You are right!

Suggestion: Add a php bin/cmd clean_ips command to remove IP:s where last_request is older than 24h or similar, otherwise the table is gonna balloon in size.

@joaquimds
Copy link
Contributor Author

joaquimds commented Oct 11, 2017

@khromov I've changed how the getRequestCountByIp function works. Now it starts by pruning any entries that are older than one hour. This also means it doesn't need to check the timestamp in the PHP code anymore. It'll mean the update requests are handled slightly slower, but also means we don't need to add another cron job :-)

@khromov
Copy link
Collaborator

khromov commented Oct 11, 2017

@joaquimds Cool! Only caveat with this is that writes lock the entire database on SQLite. I think this has improved on SQLite 3 though.* But it might introduce an additional "attack vector" in terms of DDOSing the database with write requests.

@joaquimds
Copy link
Contributor Author

joaquimds commented Oct 11, 2017

Good catch. I think the limit of 10 requests per hour should prevent that to an extent, though.

EDIT: Oh wait, no it won't!

@khromov
Copy link
Collaborator

khromov commented Oct 11, 2017

@joaquimds But the DELETE query runs on each invocation of getRequestCountByIp, so I think it would still lock the table for a short time every time someone runs /update.

@joaquimds
Copy link
Contributor Author

@khromov I've changed it so that the DELETE only happens when a new entry is added. This means that the table will still be pruned periodically, but attackers can't cause it to be pruned with every request.

@khromov
Copy link
Collaborator

khromov commented Oct 11, 2017

@joaquimds Awesome! 💯 🏆 🚢

@joaquimds joaquimds merged commit fa3f5ca into master Oct 12, 2017
@NoelLH NoelLH deleted the refresh-package-front-end-ui branch September 7, 2020 11:12
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.

2 participants