-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] string obfuscation support #2
Comments
+1 This approach is ultimately pushing the problem further along. NSHipster has a great article on this, https://nshipster.com/secrets/#normal-brain-hard-code-secrets-in-source-code |
Thanks @JackoPlane. How are you? Yup, I saw that article as well and it is really good one. I'm thinking of providing several algorithm options and whether keeping the string data type but with more secured encryption algorithm, so it will have less boilerplate/template. Or just using the same algorithm from nshipster but the downside is providing the boilerplate, because of the changes of data type from string to byte array, especially if using for other languages. What do you think? |
I'm doing well mate @michaelhenry Ultimately, everything that you ship in a mobile app should be considered "public". Typically things like API keys aren't considered sensitive, It's trivial to capture these values using something like a MiTM proxy - Even with SSL pinning (See: (SSL Kill Switch)[https://github.com/NyaMisty/ssl-kill-switch3]). Personally, my beliefs with obscuring things like API keys in mobile apps is to store them as binary and then convert to Strings (As described in the NSHipser article) at runtime. Doing so means that your raw string is no longer discovered via Unless you have a specific requirement, encoding the strings to binary and injecting that into your |
@JackoPlane Yeah, that's true, and as NSHipster says, "Client Secrecy is Impossible". It's just a matter of effort and time. And the other advantage of simply obscuring them as binary is it is much faster to decode compared to other algorithms that use thousands of iterations to perform the encryption and decryption, which is relatively slower. For simplicity, I will use this approach by replacing the key with an anonymous function if the source is a swift code. For example:Sourceenum Secrets {
var apiKey = "$API_KEY"
} Final formenum Secrets {
var apiKey = "\({ deobfuscate([0x1, 0x2, 0x3, 0x4, ..., 0x100], salt: salt) }())"
} Required codeprivate var salt = "$SALT_KEY" // bytes and will be populated automatically by `envject`.
private func deobfuscate(_ bytes: [UInt8], salt: [UInt8]) -> String {
return bytes.enumerated().reduce(into: "") {
$0.append(Character(UnicodeScalar($1.element ^ salt[$1.offset % salt.count])))
}
} And if the code is swift, I think, I'm gonna automate this What do you think? |
Ability to obfuscate env values
The text was updated successfully, but these errors were encountered: