XQuery injection is a security vulnerability similar to SQL injection, where unsafe user-supplied input manipulates XML queries, allowing attackers to access unauthorized data or elevate privileges. It occurs when user input is not properly sanitized, which can lead to authentication bypass and data extraction. To prevent such attacks, user input should be filtered or validated, and parameterized queries along with the principle of least privilege should be utilized.