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

HTTP 500 response when viewing the admin page #2494

Closed
1 task done
Tracked by #2480
douglasparker opened this issue Dec 13, 2022 · 14 comments
Closed
1 task done
Tracked by #2480

HTTP 500 response when viewing the admin page #2494

douglasparker opened this issue Dec 13, 2022 · 14 comments
Labels
bug bw-unified-deploy An Issue related to Bitwarden unified deployment

Comments

@douglasparker
Copy link

douglasparker commented Dec 13, 2022

Steps To Reproduce

  1. Deploy the bitwarden/self-host:beta docker image.
  2. Access the shell for the container by running: docker exec -it bitwarden sh
  3. Check the http response using curl: curl -IL localhost:8080/admin/login

Expected Result

I expect an http 200 response and for the admin page to be rendered.

Actual Result

I receive a http 500 response code.

root@aether:/opt/bitwarden# docker exec -it bitwarden sh
/app $ curl -IL localhost:8080/admin/login
HTTP/1.1 500 Internal Server Error
Server: nginx
Date: Tue, 13 Dec 2022 01:53:53 GMT
Content-Length: 0
Connection: keep-alive

Screenshots or Videos

No response

Additional Context

This is a fresh deployment of Bitwarden Unified using Postgres.

Githash Version

aea1991-dirty

Environment Details

  • Ubuntu 22.04
  • Docker
  • 16 Cores, 32 GB of RAM

Database Image

postgres:14

Issue-Link

#2480

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@douglasparker douglasparker added bug bw-unified-deploy An Issue related to Bitwarden unified deployment labels Dec 13, 2022
@douglasparker
Copy link
Author

docker-compose.yml

services:
  bitwarden:
    image: bitwarden/self-host:beta
    container_name: bitwarden
    depends_on: [ db ]
    environment:
      BW_DOMAIN: redacted
      BW_DB_PROVIDER: postgresql
      BW_DB_SERVER: bitwarden-db
      BW_DB_DATABASE: bitwarden
      BW_DB_USERNAME: redacted
      BW_DB_PASSWORD: redacted
      BW_INSTALLATION_ID: redacted
      BW_INSTALLATION_KEY: redacted
      globalSettings__mail__smtp__host: smtp.mailgun.org
      globalSettings__mail__smtp__port: 587
      globalSettings__mail__smtp__ssl: false
      globalSettings__mail__smtp__username: redacted
      globalSettings__mail__smtp__password: redacted
      globalSettings__mail__replyToEmail: redacted
      globalSettings__disableUserRegistration: true
      adminSettings__admins: redacted
    volumes:
      - ./data:/etc/bitwarden
    restart: unless-stopped
  
  db:
    image: postgres:14 # db not compatible with v15
    container_name: bitwarden-db
    environment:
      POSTGRES_DB: bitwarden
      POSTGRES_USER: redacted
      POSTGRES_PASSWORD: redacted
    volumes:
      - ./db:/var/lib/postgresql/data
    restart: unless-stopped

networks:
  default:
    name: internal-network

@kspearrin
Copy link
Member

Can you check application logs in /etc/bitwarden/logs for admin?

@douglasparker
Copy link
Author

douglasparker commented Dec 13, 2022

Can you check application logs in /etc/bitwarden/logs for admin?

The /etc/bitwarden directory inside of the container seems to be empty.

@kspearrin
Copy link
Member

Hmm. How about /var/logs/bitwarden. Is there anything telling in there for admin or nginx?

@douglasparker
Copy link
Author

douglasparker commented Dec 13, 2022

Hmm. How about /var/logs/bitwarden. Is there anything telling in there for admin or nginx?

/var/log/nginx/access.log

/app $ cat /var/log/nginx/access.log
172.18.0.19 - - [13/Dec/2022:20:31:57 +0000] "GET /admin/login HTTP/1.1" 500 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "71.237.146.215"

/var/log/bitwarden/admin.log

/app $ cat /var/log/bitwarden/admin.log
fail: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[48]
      An error occurred while reading the key ring.
      System.UnauthorizedAccessException: Access to the path '/etc/bitwarden/data-protection' is denied.
       ---> System.IO.IOException: Permission denied
         --- End of inner exception stack trace ---
         at System.IO.FileSystem.CreateDirectory(String fullPath)
         at System.IO.DirectoryInfo.Create()
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElementsCore()+MoveNext()
         at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElements()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.GetAllKeys()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh)
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /app/Admin
fail: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[48]
      => SpanId:82de12a4d70a6548, TraceId:d1f8cbbfeebcc520023eb32507b39d9b, ParentId:0000000000000000 => ConnectionId:0HMMT94A4R2N5 => RequestPath:/admin/login RequestId:0HMMT94A4R2N5:00000002 => Bit.Admin.Controllers.LoginController.Index (Admin)
      An error occurred while reading the key ring.
      System.UnauthorizedAccessException: Access to the path '/etc/bitwarden/data-protection' is denied.
       ---> System.IO.IOException: Permission denied
         --- End of inner exception stack trace ---
         at System.IO.FileSystem.CreateDirectory(String fullPath)
         at System.IO.DirectoryInfo.Create()
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElementsCore()+MoveNext()
         at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElements()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.GetAllKeys()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh)
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
      => SpanId:82de12a4d70a6548, TraceId:d1f8cbbfeebcc520023eb32507b39d9b, ParentId:0000000000000000 => ConnectionId:0HMMT94A4R2N5 => RequestPath:/admin/login RequestId:0HMMT94A4R2N5:00000002
      An unhandled exception has occurred while executing the request.
      System.Security.Cryptography.CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. For more information go to http://aka.ms/dataprotectionwarning
       ---> System.UnauthorizedAccessException: Access to the path '/etc/bitwarden/data-protection' is denied.
       ---> System.IO.IOException: Permission denied
         --- End of inner exception stack trace ---
         at System.IO.FileSystem.CreateDirectory(String fullPath)
         at System.IO.DirectoryInfo.Create()
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElementsCore()+MoveNext()
         at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElements()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.GetAllKeys()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRing()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)
         --- End of inner exception stack trace ---
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)
         at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Serialize(AntiforgeryToken token)
         at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.Serialize(IAntiforgeryFeature antiforgeryFeature)
         at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.GetAndStoreTokens(HttpContext httpContext)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.AntiforgeryExtensions.GetHtml(IAntiforgery antiforgery, HttpContext httpContext)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultHtmlGenerator.GenerateAntiforgery(ViewContext viewContext)
         at Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Process(TagHelperContext context, TagHelperOutput output)
         at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
         at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)
         at AspNetCoreGeneratedDocument.Views_Login_Index.ExecuteAsync() in /source/src/Admin/Views/Login/Index.cshtml:line 14
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
         at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|22_0(ResourceInvoker invoker, IActionResult result)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
fail: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[48]
      => SpanId:82de12a4d70a6548, TraceId:d1f8cbbfeebcc520023eb32507b39d9b, ParentId:0000000000000000 => ConnectionId:0HMMT94A4R2N5 => RequestPath:/admin/login RequestId:0HMMT94A4R2N5:00000002 => Bit.Admin.Controllers.ErrorController.Error (Admin)
      An error occurred while reading the key ring.
      System.UnauthorizedAccessException: Access to the path '/etc/bitwarden/data-protection' is denied.
       ---> System.IO.IOException: Permission denied
         --- End of inner exception stack trace ---
         at System.IO.FileSystem.CreateDirectory(String fullPath)
         at System.IO.DirectoryInfo.Create()
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElementsCore()+MoveNext()
         at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElements()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.GetAllKeys()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh)
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[3]
      => SpanId:82de12a4d70a6548, TraceId:d1f8cbbfeebcc520023eb32507b39d9b, ParentId:0000000000000000 => ConnectionId:0HMMT94A4R2N5 => RequestPath:/admin/login RequestId:0HMMT94A4R2N5:00000002
      An exception was thrown attempting to execute the error handler.
      System.Security.Cryptography.CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. For more information go to http://aka.ms/dataprotectionwarning
       ---> System.UnauthorizedAccessException: Access to the path '/etc/bitwarden/data-protection' is denied.
       ---> System.IO.IOException: Permission denied
         --- End of inner exception stack trace ---
         at System.IO.FileSystem.CreateDirectory(String fullPath)
         at System.IO.DirectoryInfo.Create()
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElementsCore()+MoveNext()
         at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElements()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.GetAllKeys()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRing()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)
         --- End of inner exception stack trace ---
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.CookieTempDataProvider.SaveTempData(HttpContext context, IDictionary`2 values)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.TempDataDictionary.Save()
         at Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.SaveTempDataFilter.SaveTempData(IActionResult result, ITempDataDictionaryFactory factory, IList`1 filters, HttpContext httpContext)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.Filters.SaveTempDataFilter.OnResultExecuted(ResultExecutedContext context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      => SpanId:82de12a4d70a6548, TraceId:d1f8cbbfeebcc520023eb32507b39d9b, ParentId:0000000000000000 => ConnectionId:0HMMT94A4R2N5 => RequestPath:/admin/login RequestId:0HMMT94A4R2N5:00000002
      Connection id "0HMMT94A4R2N5", Request id "0HMMT94A4R2N5:00000002": An unhandled exception was thrown by the application.
      System.Security.Cryptography.CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. For more information go to http://aka.ms/dataprotectionwarning
       ---> System.UnauthorizedAccessException: Access to the path '/etc/bitwarden/data-protection' is denied.
       ---> System.IO.IOException: Permission denied
         --- End of inner exception stack trace ---
         at System.IO.FileSystem.CreateDirectory(String fullPath)
         at System.IO.DirectoryInfo.Create()
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElementsCore()+MoveNext()
         at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElements()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.GetAllKeys()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRing()
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)
         --- End of inner exception stack trace ---
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)
         at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Serialize(AntiforgeryToken token)
         at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.Serialize(IAntiforgeryFeature antiforgeryFeature)
         at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.GetAndStoreTokens(HttpContext httpContext)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.AntiforgeryExtensions.GetHtml(IAntiforgery antiforgery, HttpContext httpContext)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultHtmlGenerator.GenerateAntiforgery(ViewContext viewContext)
         at Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper.Process(TagHelperContext context, TagHelperOutput output)
         at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
         at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)
         at AspNetCoreGeneratedDocument.Views_Login_Index.ExecuteAsync() in /source/src/Admin/Views/Login/Index.cshtml:line 14
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
         at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|22_0(ResourceInvoker invoker, IActionResult result)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
         at Microsoft.AspNetCore.Builder.Extensions.UsePathBaseMiddleware.InvokeCore(HttpContext context, PathString matchedPath, PathString remainingPath)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

@kspearrin
Copy link
Member

Looks like a permissions issue with /etc/bitwarden/data-protection.

@vgrassia Do you know why this would happen. Is it related to #2483?

@vgrassia
Copy link
Member

vgrassia commented Dec 13, 2022

@kspearrin Yes, I believe it's related to #2483. I would use the dev tag for the image and set the UID and GID to the necessary values and try again.

@douglasparker
Copy link
Author

@kspearrin Yes, I believe it's related to #2483. I would use the dev tag for the image and set the UID and GID to the necessary values and try again.

I’m wanting to use the Unified Beta. Wouldn't the dev tag be more unstable?

Furthermore, the documentation doesn’t mention uid and gid. Are there not any sane defaults when these environmental variables are omitted?

@kspearrin
Copy link
Member

Yes, this fix was just added earlier today so it's not in a published beta release yet. You would have to use the dev tag to get it, which just builds off of the master branch. It would not be stable. This is also why it is not yet documented.

Currently the containers use UID and GID of 1000:1000. I believe this causes permissions issues if that does not align with an actual user on your host system. Do you know what your user and group id are on the host?

@douglasparker
Copy link
Author

Do you know what your user and group id are on the host?

I believe the root user has a uid and gid of 0.

Wouldn’t it make more sense to run with a uid and gid of 0 if not defined?

@kspearrin
Copy link
Member

I'll let @vgrassia chime in, but I think we don't want to run as root by default, which is the point of creating a user like we have.

@douglasparker
Copy link
Author

I'll let @vgrassia chime in, but I think we don't want to run as root by default, which is the point of creating a user like we have.

This is understandable! I think that a better solution would be to output an error message if someone tries to run as root.

Preferably in a way that can be checked when running docker logs bitwarden -f as that is the first thing I run when checking for something going wrong, this way we don’t have to sift through multiple log files.

Anyways, thank you for the help! I’ll setup Bitwarden to run as a non root user and switch to the dev tag or wait for a beta update.

@douglasparker
Copy link
Author

I can confirm that using the bitwarden/self-host:dev image and setting a UID and GID environmental variable fixed this problem. Good work and thanks for the help!

@justindbaur
Copy link
Member

Thanks for your help getting to the bottom of the issue @douglasparker. I'm going to close this as also fixed by #2495.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bw-unified-deploy An Issue related to Bitwarden unified deployment
Projects
None yet
Development

No branches or pull requests

4 participants