GithubHelp home page GithubHelp logo

4n6ir / getpublicip Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 6.38 MB

Capture the Public IP Address during Lambda execution for CloudTrail correlation.

Home Page: https://gallery.ecr.aws/forensicir/getpublicip

License: Apache License 2.0

Python 98.22% Shell 0.58% Dockerfile 1.20%
cdk lambda extension aws ip layer serverless aws-lambda container docker

getpublicip's Introduction

getpublicip

The Lambda Extension allows you to attach an existing Function to run in the same execution environment by sharing CPU, Memory, Disk Storage, Environment Variables, and IAM Permissions. Lambda supports up to 10 extensions (multiple per layer) and up to 5 layers per function, counting against the unzipped deployment package size limit of 250 MB. It adds benefits but introduces potential threats that justify defining an SCP to mitigate the risk.

Potential Threats:
  • Do you trust the external Lambda Extension or Lambda Layer attached to the Lambda Function not to inject malicious code?
  • The extension could add code dependencies that may introduce vulnerabilities or provide a means for notorious activities.
  • Lambda Layers do not show if they are publically shared or have access granted to external AWS Accounts in the console.

I have created Lambda Extention that captures the Public IP Address by visiting this AWS site to help reduce the request latency.

https://checkip.amazonaws.com

The Lambda Extension returns the following log entry in the Cloud Watch Logs. The account number is only available if the AWS_ACCOUNT environment variable is part of the Lambda deployment.

{
    "publicip": "34.220.123.1",
    "timestamp": "09/08/2023 02:43:32.379936 UTC",
    "function": "AmazonblocksStack-gtfobin14961F10-bvnpSnvvSSfH",
    "region": "us-west-2",
    "account": "070176467818"
}
AWS Serverless Application Repository

https://serverlessrepo.aws.amazon.com

Cloud Development Kit (CDK) v2
        region = Stack.of(self).region

        layer = _lambda.LayerVersion.from_layer_version_arn(
            self, 'layer',
            layer_version_arn = 'arn:aws:lambda:'+region+':070176467818:layer:getpublicip:12'
        )
Amazon ECR Public Gallery
public.ecr.aws/forensicir/getpublicip:latest

https://gallery.ecr.aws/forensicir/getpublicip

Lambda Container Extension
### 2.136.0 (build 94fd33b) ###
FROM 070176467818.dkr.ecr.us-west-2.amazonaws.com/getpublicip:latest AS layer
FROM public.ecr.aws/lambda/python:latest
RUN yum -y update && yum clean all
### layer code ###
WORKDIR /opt
COPY --from=layer /opt/ .
### function code ###
WORKDIR /var/task
COPY gtfobin.py requirements.txt .
RUN pip --no-cache-dir install -r requirements.txt --upgrade
CMD ["gtfobin.handler"]
Regions
  • us-east-1
  • us-east-2
  • us-west-2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.