In general, security guards can only search your bags if you give them permission or they have a warrant. However, there may be some exceptions to this rule depending on the circumstances (e.g., if you are entering a secure area).