Skip to content

Sensitive data masking utility #1173

Closed

Description

@heitorlessa

Runtime e.g. Python, Java, all of them. Python

Is your feature request related to a problem? Please describe.

As a customer, I'd like to obfuscate incoming data for known fields that contain PII, so that they're not passed downstream or accidentally logged.

Describe the solution you'd like

It could be any of these ideas or something better if anyone wants to chime in:

A more complex operation would be for data depersonalization where I'd want to encrypt and store the correct data somewhere, in which a separate actor would have permission to decrypt it.

Describe alternatives you've considered

  1. Mask data on my own with a function that walks through a graph and recursively change it.
  2. Use Amazon Comprehend Medical to detect PHI data, convert it to a str, and run a string replacement to mask any sensitive data encountered

Is this something you'd like to contribute if you had guidance?

Additional context

Activity

  1. michaelbrewer commented on Jul 28, 2021

    @michaelbrewer
    Contributor

    @heitorlessa - would you be able to help put more details on how this could be implemented? It might be something i can have a look into.

  2. keithrozario commented on Aug 11, 2021

    @keithrozario

    My idea was something like this:

    from aws_lambda_powertools import Logger
    from aws_lambda_powertools import obfuscation_filter
    
    logger = Logger(service="payment")
    
    @logger.inject_lambda_context
    def lambda_handler(event, context):
    
        logger.info(event)
        #   {
        #     Records: [
        #         { firstName: "personal" secondName: "identifiable" email: "inform@ti.on", groupID: "123" },
        #         { firstName: "second" secondName: "personal" email: "inform@ti.on", some_other_value: "abc" }
        #       ]
        #   }
    
        # pass object and list of json paths to obfuscate
        obfuscation_filter(
            object=event,
            obfuscation_paths=["Records.*.firstName", "Records.*.secondName", "Records.*.email"]
        )
    
        logger.info(event)
        # {
        #   Records: [
        #       { firstName: "********" secondName: "************" email: "******@**.**", groupID: "123" },
        #       { firstName: "******" secondName: "********" email: "******@**.**", some_other_value: "abc" }
        #     ]
        # }

    thoughts?

  3. heitorlessa commented on Aug 11, 2021

    @heitorlessa
    ContributorAuthor

    I couldn't block time to speak to a few Security experts on the best way to do this. One thing I know for sure is that not only you want to mask data, but there are times you want to encrypt it from one party and decrypt only from another party -- it could be optional.

    Recursion works, AST also works, JMESPath wouldn't work as you can't do an in-place edit nor know the nodes you travelled.

    Let me ping some Security experts to get their opinion on it.

  4. heitorlessa commented on Aug 11, 2021

    @heitorlessa
    ContributorAuthor

    My idea was something like this:

    from aws_lambda_powertools import Logger
    from aws_lambda_powertools import obfuscation_filter
    
    logger = Logger(service="payment")
    
    @logger.inject_lambda_context
    def lambda_handler(event, context):
    
        logger.info(event)
        #   {
        #     Records: [
        #         { firstName: "personal" secondName: "identifiable" email: "inform@ti.on", groupID: "123" },
        #         { firstName: "second" secondName: "personal" email: "inform@ti.on", some_other_value: "abc" }
        #       ]
        #   }
    
        # pass object and list of json paths to obfuscate
        obfuscation_filter(
            object=event,
            obfuscation_paths=["Records.*.firstName", "Records.*.secondName", "Records.*.email"]
        )
    
        logger.info(event)
        # {
        #   Records: [
        #       { firstName: "********" secondName: "************" email: "******@**.**", groupID: "123" },
        #       { firstName: "******" secondName: "********" email: "******@**.**", some_other_value: "abc" }
        #     ]
        # }

    thoughts?

    That's a similar UX we would be looking at. I've pinged two security experts I trust at AWS to help brainstorm this, but here's essentially the problem space we're looking at.

    1. As a customer, I'd like to mask sensitive data my function is receiving so that downstream systems will not need any additional work on handling PII data.
    2. As a customer, I'd like to recover sensitive data masked into its original form so that I can handle sensitive requests around that data on a as-needed basis.

    We can handle 1 without any tokenization process, however if we ever want to support 2 we would need tokenization to obfuscate and de-obfuscate data in separate operations, and the latter being done only by authorised personnel.

    There could be simpler ways to do it without bringing a heavy dependency but given tokenisation is serious thing and must be uniquely random we need to be careful, hence some Security experts opinion first.... or else we might end up with 1 only that's similar to what you did @keithrozario

  5. keithrozario commented on Aug 12, 2021

    @keithrozario

    True, my understanding of tokenization is that it requires a store of data (unlike encryption). It'll be quite difficult to execute either tokenization or encryption without some external service providing that functionality.

  6. michaelbrewer commented on Dec 4, 2021

    @michaelbrewer
    Contributor

    I might look a little more into this. Especially once we feel like the UX it there for this.

  7. faboulaye commented on Apr 21, 2022

    @faboulaye

    Any update about this issue ?

  8. dreamorosi commented on Apr 21, 2022

    @dreamorosi
    Contributor

    Any update about this issue ?

    Hi @faboulaye, please see #1076 for info on the current status of AWS Lambda Powertools for Python.

    For the TypeScript version we have a similar feature request (#728) but at the moment we are focused on refining the experience for the core utilities (Logger, Tracer, Metrics) before considering new feature requests.

  9. ammar-khan-cultureamp commented on Jul 6, 2022

    @ammar-khan-cultureamp

    I have implemented this before in Java and my thoughts are not to mention path because it will be very messy for larger projects, just mentioned the fields which needs masking, my idea is:

    # example log event:
    #   {
    #     Records: [
    #         { firstName: "personal" secondName: "identifiable" email: "inform@ti.on", groupID: "123" },
    #         { firstName: "second" secondName: "personal" email: "inform@ti.on", some_other_value: "abc" }
    #     ]
    #   }
    
    from aws_lambda_powertools import Logger
    
    logger = Logger(service="payment")
    
    @logger.inject_lambda_context
    @logger.obfuscation({fields: ["firstName", "secondName", "email"]}) # This can be move to a config file
    def lambda_handler(event, context):
        logger.info(event)
        
    # Push logs to cloud watch as:
    # {
    #   Records: [
    #       { firstName: "********" secondName: "************" email: "******@**.**", groupID: "123" },
    #       { firstName: "******" secondName: "********" email: "******@**.**", some_other_value: "abc" }
    #     ]
    # }
    
  10. added
    help wanted
    on Aug 1, 2022
  11. 8 remaining items

  12. removed their assignment
    on Feb 6, 2023
  13. justinhauer commented on Jul 31, 2023

    @justinhauer

    @heitorlessa is still set to be added?

  14. heitorlessa commented on Jul 31, 2023

    @heitorlessa
    ContributorAuthor

    Yea @justinhauer - I had to prioritise supply chain security work so it slipped. I spoke with Seshu (author) last week, and I'm reviewing this week.

  15. github-actions commented on Sep 27, 2023

    @github-actions
    Contributor

    ⚠️COMMENT VISIBILITY WARNING⚠️

    This issue is now closed. Please be mindful that future comments are hard for our team to see.

    If you need more assistance, please either tag a team member or open a new issue that references this one.

    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requesthelp wanted

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions