Covenant icon indicating copy to clipboard operation
Covenant copied to clipboard

[Bug] Covenant Crashes When BindAdress for Listener Unavailable

Open er4z0r opened this issue 2 years ago • 3 comments

Feature Request or Bug Bug

Describe the feature request or bug When a covenant listener was previously configured to start on a specific IP (e.g. the one of a tun0 interface of a VPN connection) that is not available during startup covenant will fail to start.

To Reproduce Steps to reproduce the behavior:

  1. Confiugre a Listener bound to a specific IP
  2. Stop Covenant
  3. Down the interface
  4. Start Covenant again

Expected behavior Covenant warns about the IP not being available, but starts correctly.

Observed behavior Covenant crashes with the following stacktrace:

Unhandled exception. System.AggregateException: One or more errors occurred. (BadRequest - Listener with id: 2 did not start due to exception: One or more errors occurred. (Cannot assign requested address))    
 ---> Covenant.Core.ControllerBadRequestException: BadRequest - Listener with id: 2 did not start due to exception: One or more errors occurred. (Cannot assign requested address)                                
   at Covenant.Core.CovenantService.StartListener(Int32 listenerId) in /home/user/Covenant/Covenant/Core/CovenantService.cs:line 4532                                                                             
   at Covenant.Core.DbInitializer.InitializeListeners(ICovenantService service, CovenantContext context, CovenantUser user) in /home/user/Covenant/Covenant/Core/DbInitializer.cs:line 103                        
   at Covenant.Core.DbInitializer.Initialize(ICovenantService service, CovenantContext context, RoleManager`1 roleManager, UserManager`1 userManager, String username, String password) in /home/user/Covenant/Cov
enant/Core/DbInitializer.cs:line 30                                                                                                                                                                               
   --- End of inner exception stack trace ---                                                                                                                                                                     
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)                                                                                                            
   at System.Threading.Tasks.Task.Wait()                                                                                                                                                                          
   at Covenant.Program.<>c__DisplayClass0_0.<Main>b__0() in /home/user/Covenant/Covenant/Covenant.cs:line 114                                                                                                     
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass146_0.<OnExecute>b__0(CancellationToken _)                                                                                     
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)                                                                                
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)                                                                                                                          
   at Covenant.Program.Main(String[] args) in /home/user/Covenant/Covenant/Covenant.cs:line 136                      

Covenant Server Information:

  • OS: Kali GNU/Linux Rolling
  • Native

er4z0r avatar Jul 11 '22 08:07 er4z0r

Workaround for anyone facing this issue (tooling may vary depending on your OS):

  1. Go to Covenant/Covenant folder
  2. Create backup of Data/covenant.db: tar cvJf covenant.db.tar.xz Data/covenant.db
  3. Open the database using sqlite3: sudo sqlite3 Data/covenant.db
  4. Check for the problematic listener (the one with the IP that is no longer bound to any of your interfaces): sqlite> select Name,BindAddress,BindPort from Listeners;
  5. Update the listener to bind to any IP: sqlite> Update Listeners SET BindAddress='0.0.0.0' WHERE Name='HTTPListenerStudentVM'; 5a. Alternatively (modifying all listeners): sqlite> Update Listeners SET BindAddress='0.0.0.0';

HTH.

er4z0r avatar Jul 11 '22 08:07 er4z0r

Looks like a dup of #348

rasta-mouse avatar Jul 11 '22 08:07 rasta-mouse

Indeed. Closing as dup.

er4z0r avatar Jul 11 '22 09:07 er4z0r