Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,457,987
Community Members
 
Community Events
176
Community Groups

Webhook security between bitbucket cloud and AWS?

I have a web hook registered to call the Jenkins BitBucket Push and Pull Request Plugin running in Jenkins on AWS.  The EC2 instance on which Jenkins is running is bound to an Elastic IP address (i.e., static IP).  How do I secure the calls to allow legitimate calls from bitbucket cloud through but not expose Jenkins to rogue calls?

The webhook infrastructure in bitbucket does not appear to support the use of credentials and the CIDR list of where these calls could originate is daunting.  Is my only choice to punt and drop back to polling bitbucket.org from Jenkins?

1 answer

There does indeed not seem to be an official Bitbucket Cloud approach for this common problem (would assume there is a related feature request, but couldn't find it right away).

I'd consider a workaround along the following lines:

Potential workaround

Your goal is to identify and ideally authenticate the Bitbucket Cloud webhook as early as possible so that rogue traffic doesn't even reach Jenkins or the EC2 instance in the first place.

A common pattern for this is to provide resp. authentication tokens, ideally within the HTTP request headers (as e.g. supported by Jira Service Desk webhooks), or at least as an HTTP query parameter as a fallback, here are two examples:

Now, within AWS you have a couple of edge services that allow you to achieve that one way or another, again just briefly to give you an idea where to start:

  • Amazon API Gateway + AWS Lambda, ideally via API Gateway Lambda Authorizers, or just a custom token (see example below) - "A Lambda authorizer is useful if you want to implement a custom authorization scheme that uses a bearer token authentication strategy such as OAuth or SAML, or that uses request parameters to determine the caller's identity. [emphasis mine]"
  • Amazon CloudFront + AWS Lambda@Edge - "Inspect headers or authorized tokens, inserting a corresponding header and allowing access control before forwarding a request to the origin. [emphasis mine]"

Both approaches already deflect most traffic at the network edge, and you can optionally further refine and control that with AWS WAF (Web Application Firewall (would e.g. allow to still use that daunting CIDR list and only check the token as a secondary line of defense).

I would also assume there are a few OSS projects that already implement those pattern, at least for related scenarios that may be easy to adopt, here's one each:

Good luck, and please share what you come up with!

We migrated away from BitBucket to GitHub to get a real solution without requiring complex workarounds...

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events