GithubHelp home page GithubHelp logo

Comments (7)

mholt avatar mholt commented on September 28, 2024

This is a valid concern. I'll look into it soon, and others are welcome to as well. Thanks for bringing it up!

from go-aws-auth.

peterbourgon avatar peterbourgon commented on September 28, 2024

That synchronizes the signing, but clients still must write to the package global Keys manually whenever credentials are updated. If that happens more often than at program start (i.e. in func init) they still need to bring their own synchronization, to prevent data races.

from go-aws-auth.

mholt avatar mholt commented on September 28, 2024

@peterbourgon This is true. I just glanced at the code again, and the only time that I can see that the credentials are updated within the package is when a signing request is made, and fortunately, those are all within the mutex (the checkKeys() function). To update credentials yourself, then, yes, using your own mutex would be a good idea. (I think my logic is okay here, but I may be wrong since I haven't tested that scenario.)

from go-aws-auth.

peterbourgon avatar peterbourgon commented on September 28, 2024

To update credentials yourself, then, yes, using your own mutex would be a good idea.

Well, it's not just a good idea—it's a data race if you don't. Actually, even if you claimed that local clientMutex, another goroutine could still call a Sign method, claim the package signMutex, which could cause a mutation and trigger another data race :(

Problems, as I see them:

  1. checkKeys() implies read-only access; that it mutates Keys is very confusing!
  2. checkKeys() relies on the caller claiming the signMutex—very fragile.
  3. checkKeys() pulling information from os.Getenv is spooky action at a distance :(

I'm afraid the current architecture is inherently unsafe. The Keys credentials should be wrapped (i.e. not available as a package global), explicitly initialized (i.e. no implicit os.Getenv), and all access synchronized through a clear API boundary provided by the package.

from go-aws-auth.

mholt avatar mholt commented on September 28, 2024

Is changing the credentials something you do frequently?

from go-aws-auth.

peterbourgon avatar peterbourgon commented on September 28, 2024

Of course. Imagine a program that uses multiple credentials to make distinct requests on different periodic intervals.

from go-aws-auth.

mholt avatar mholt commented on September 28, 2024

Alright, we'll use issue #14 to resolve this; thanks!

from go-aws-auth.

Related Issues (20)

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.