Bitbucket Server で CAPTCHA を構成する方法

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

要約

Bitbucket Server のエンドユーザーやビルド システムで CAPTCHA の頻繁なクリアが必要な場合

この場合、CAPTCHA 認証が有効化されていて、誤った資格情報でリポジトリをクローンしようとしているスクリプトがどこかに存在する可能性があります。Bitbucket で CAPTCHA への入力が要求されているため、任意の外部ツール (git クライアント: Sourcetree、TortoiseGit) が Bitbucket サーバーのリポジトリにアクセスしようとしたときにアクセスが拒否されます。これはランダムで発生し、自動化されたビルド環境では大きなフラストレーションにつながる可能性があります。

セキュリティ上の理由のため、CAPTCHA を無効化するよりも、誤ったユーザー名/パスワードでログインに失敗しているものを絞り込むことをおすすめします。

CAPTHA の無効化方法については以降のガイドをご確認ください。

ブロックされているユーザーを特定する方法

ご利用のインスタンスで監査ログを有効化できます。

  • 監査ログの表示と設定
    • Set the Coverage level of the Security coverage area to Advanced.
  • BITBUCKET_HOME/log/audit で次のようなエントリを探します。

    • 7.0 よりも前のバージョンの監査ログ 
0:0:0:0:0:0:0:1 | AuthenticationFailureEvent | - | 1392111196025 | username | {"authentication-method":"form","error":"Invalid username or password."} | 633x670x0 | 1xzqso0
    • 新しい形式を利用した監査ログ (Bitbucket 7 以降)
{"affectedObjects":[],"auditType":{"action":"User login failed","actionI18nKey":"bitbucket.service.user.audit.action.authenticationfailure","area":"SECURITY","category":"Authentication","categoryI18nKey":"bitbucket.service.audit.category.authentication","level":"ADVANCED"},"author":{"id":"-2","name":"Anonymous","type":"user"},"changedValues":[],"extraAttributes":[{"name":"Error","nameI18nKey":"bitbucket.service.user.audit.attribute.authenticationfailure.error","value":"Authentication failed because the user does not exist, the account is inactive, or the provided credentials are incorrect"},{"name":"Authentication method","nameI18nKey":"bitbucket.service.user.audit.attribute.authentication.authmethod","value":"form"}],"method":"Browser","node":"57fbe9e0-9dd1-4945-a1d1-a6e089c35601","source":"0:0:0:0:0:0:0:1","system":"https://localhost:8443","timestamp":{"epochSecond":1654877306,"nano":166000000},"version":"1.0"}


Bitbucket のデータベースで次のクエリを利用することもできます。

SELECT us.user_name
FROM cwd_user_attribute as atr
JOIN cwd_user as us ON atr.user_id=us.id
WHERE atr.attribute_name = 'failedAuthenticationAttemptCount' AND CAST(atr.attribute_value as integer) >= 5 ;


CAPTCHA でユーザーがブロックされる問題のよくある原因

ソリューション

特定のユーザー向けに CAPTCHA をクリアする方法

ユーザー ページで自身に "システム管理者" グローバル権限が直接割り当てられていると、Bitbucket Server の CAPTCHA をクリアできます。

CAPTCHA の無効化方法

For security reasons, Bitbucket Server end users will be prompted to enter CAPTCHA after failing to log in 5 times in a row. This value is set by default.

CAPTCHA は無効化できます。ただし当社では、この機能はデフォルトで有効化すべきで、無効化にはリスクがある (例: 総当たり攻撃) と考えているため、Bitbucket Server の管理 UI に無効化機能を表示していません。

CAPTCHA を無効化すると次の影響が考えられます。

  • Bitbucket Server がすべての認証リクエストを (これまでの失敗回数にかかわらず) 基盤となっているディレクトリ サービスに送信するため、ユーザーが基盤となっているユーザー ディレクトリ サービス (LDAP、Active Directory など) から自身をロックアウトしてしまう可能性があります。
  • Bitbucket Server をユーザー管理に利用している Bitbucket Server インストールや、ユーザーをロックアウトするためのログイン失敗回数の制限がないディレクトリ サービスを利用している場合、Bitbucket Server やディレクトリ サービスをパスワードの総当たり攻撃に開示することになります。

認証の一環としての CAPTCHA を無効化するには、Bitbucket Server 3.2 以降のリリースの場合は BITBUCKET_HOME/shared]/bitbucket.properties以前のリリースの場合は BITBUCKET_HOME/ bitbucket.propertiesfeature.auth.captcha プロパティを false に設定します。

Bitbucket Server のホーム ディレクトリの共有フォルダに bitbucket.properties ファイルが存在しない場合は作成する必要があります。システム プロパティ feature.auth.captcha=false を追加します。

デフォルトの値は true です。

Bitbucket Server must be restarted after making this change for it to take effect.

UI で表示される "サインアップ時の CAPTCHA" とは


この CAPTCHA のユースケースは、上で説明したログイン時の CAPTCHA とは完全に異なるものです。以降で詳細をお読みください。


You can find the screen below under Administration Cog Icon >> Authentication

This screen is related to the "Public Sign up" feature (whether to enable it or not) in Bitbucket Server. The "Public Sign Up" feature (when enabled) allows external users to create accounts on your Bitbucket Server instance through the login screen. Thus you might be able to make sure only humans are signing up to your public instance by enabling CAPTCHA. Notice that the CAPTCHA option can only be enabled if you "Allow public sign up".

この機能を有効化すると、Bitbucket Server のログイン画面に次の要素が追加されます。

The CAPTCHA option on the first image refers to enabling CAPTCHA during the "Public Sign up" process and has nothing to do with the login CAPTCHA. See, for example, a signup screen for an instance that's got it enabled:

試行の失敗回数の増加につながる条件

  • Personal access tokens will NOT trigger a captcha even with repeated auth failures.

The CAPTCHA message is displayed after five consecutive failed login attempts. All of the following ways count towards the limit:

  • ユーザー インターフェイスのログイン画面
  • コマンド ラインを利用した、認証を必要とする git 操作 (例: git push)
  • REST API のエンドポイントの呼び出し


AuthenticationFailureEvent と failedAuthenticationAttemptCount について
BSERV-9904 - Getting issue details... STATUS にあるように、特定の条件において、監査ログで AuthenticationFailureEvent が二度記録されます。ただし、これが単一のログイン試行で failedAuthenticationAttemptCount を増やすことはありません。


言い換えると、AuthenticationFailureEvent が一度のみ記録され、クローン URL にパスワードが含まれない場合、failedAuthenticationAttemptCount は増えません。つまり、この結果として、設定された認証失敗回数よりも前に CAPTCHA メッセージが表示されることはありません (Bitbucket バージョン 5.11.1 で検証済み)。

同じユーザーに対して短期間で AuthenticationFailureEvent が 2 回記録されている場合、認証に実際に失敗しています。

ユーザーが CAPTCHA のしきい値に到達した場合の表示内容

ユーザーの次回のログイン時に次の画面が表示されます。

  • ユーザー インターフェイス経由でログインする場合は CAPTCHA 画面


  • コマンドラインから git 操作を行う場合は次のメッセージ

    fatal: remote error: CAPTCHA required
    Your Bitbucket account has been locked. To unlock it and log in again you must
    solve a CAPTCHA. This is typically caused by too many attempts to login with an
    incorrect password. The account lock prevents your SCM client from accessing
    Bitbucket and its mirrors until it is solved, even if you enter your password
    correctly.
    
    If you are currently logged in to Bitbucket via a browser you may need to
    logout and then log back in in order to solve the CAPTCHA.
    
    Visit Bitbucket at <Bitbucket_Server_url> for more details.
  • the following message when performing a REST API endpoint call

    {"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}[root@localhost tmp]# <REST API end point command details>
    {"errors":[{"context":null,"message":"CAPTCHA required. Your Bitbucket account has been locked. To unlock it and log in again you must solve a CAPTCHA. This is typically caused by too many attempts to login with an incorrect password. The account lock prevents your SCM client from accessing Bitbucket and its mirrors until it is solved, even if you enter your password correctly.\n\nIf you are currently logged in to Bitbucket via a browser you may need to logout and then log back in in order to solve the CAPTCHA.\n\nVisit Bitbucket at <Bitbucket_Server_url> for more details.","exceptionName":"com.atlassian.bitbucket.auth.CaptchaRequiredAuthenticationException"}]} 

Bitbucket Server で CAPTCHA が連続的に要求される問題につながる可能性のある条件

  • CAPTCHA will be reset only after a successful login. If the failed login count configured for Bitbucket server and AD/LDAP is the same, a user account may get locked in the AD/LDAP after the failed attempts and Bitbucket triggers CAPTCHA. This will never be cleared as the user will never be able to log in until the account gets unlocked in AD/LDAP. This may be mistaken as Bitbucket Server continuously asking CAPTCHA.  


説明

Bitbucket Server のエンドユーザーやビルド システムで CAPTCHA を頻繁にクリアする必要がある場合、CAPTCHA 認証が有効化されていて、誤った資格情報でリポジトリをクローンしようとしているスクリプトがどこかに存在する可能性があります。 

製品Bitbucket
プラットフォームServer
最終更新日: 2023 年 12 月 1 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.