sensu-go icon indicating copy to clipboard operation
sensu-go copied to clipboard

Git issue #5009 Asset cache can lead to denial of service if asset database is deleted -Fix

Open SudhanshuBawane opened this issue 1 year ago • 4 comments

Closed #5009

Description

The change is regarding the denial of service from agent when asset.db gets deleted due to some external scenario. Which creates a DOS as SHA contains the some reference to the previous asset.db and hence forth the new one does not get created properly.

Change in behavior

To prevent the DOS of the agent in above scenario and keep the agent working properly. For new asset.db creation.

Added

  • The new cleanUp function for cleaning up the SHA dir from cache to prevent a DOS in case of asset.db deletion.
  • Added the test to check all scenarios.

Changed

  • The expandWithDuration function in boltdb_manager has been changed a little for the cleanUp function support.

Fixed

  • This fixes the DOS in agent in case of asset database is deleted.

Change verification

The changes can be verified not only by the test cases but also by checking the same behavior. That is delete the asset.db and make note of it's size. Then re-run the agent and it will run without populating error file exits and asset.db get recreated with same size.

SudhanshuBawane avatar Feb 01 '24 05:02 SudhanshuBawane

A couple of minor things but looks good otherwise!

fguimond avatar Feb 13 '24 02:02 fguimond

Don't forget to add a changelog entry.

fguimond avatar Feb 29 '24 14:02 fguimond

Please add a test that shows that the boltdb manager now exhibits correct behaviour when the asset.db has been deleted

SudhanshuBawane avatar Mar 19 '24 09:03 SudhanshuBawane

Please add a test that shows that the boltdb manager now exhibits correct behaviour when the asset.db has been deleted

May I know what kind of behavior is expected like what I need to check ?

SudhanshuBawane avatar Mar 19 '24 09:03 SudhanshuBawane