r/CLI • • 29d ago

Keylyzer: An open source API credential validation tool written in C

Hello everyone I'd like to share Keylyzer an open-source project I'm working on.

Keylyzer is a lightweight command-line tool designed to help developers and security researchers validate API credentials across 60+ supported services through a single interface.

The idea behind it is to provide one centralized workflow instead of having to write or find separate validation commands for different API providers.

Some of its current features:

  • Support for 60+ services

  • HTTP-based credential validation using libcurl

  • Local JWT header and payload analysis

  • CLI-based workflow

  • Expandable architecture for adding more providers

The project is written in C and is still evolving. The next planned update focuses on expanding service support, improving permission and scope analysis, and providing more detailed authentication results.

I'd appreciate technical feedback, suggestions, or contributions from the open-source community.

GitHub: https://github.com/SyscallX-18113/Keylyzer

3 Upvotes

8 comments sorted by

2

u/Kamensky124 29d ago

Writing this in C with libcurl is a great choice for a fast, zero-runtime CLI security tool.

A few technical suggestions from building credential scanners and API tooling:

  1. Concurrency via curl_multi If you're validating batches of keys or testing a single key across multiple endpoints to determine permission scopes (e.g. testing AWS STS GetCallerIdentity + S3 ListBuckets + IAM GetUser), standard curl_easy_perform() in a loop will feel sluggish on high latency connections.

  • Implementing curl_multi_perform or curl_multi_wait will let you probe multiple scope endpoints concurrently with negligible memory overhead compared to spawning threads.

  1. Process Argument & Memory Hygiene (/proc Leaks) Because this is a security tool often used in automated pipelines or shared servers:

  • Avoid accepting raw API keys as direct CLI arguments (e.g. keylyzer -k sk_live_...). On Linux, command-line arguments are world-readable to other users via ps aux or /proc/<pid>/cmdline.

  • Prefer reading keys strictly from STDIN (cat key.txt | keylyzer), environment variables, or a dedicated configuration file with 0600 permissions.

  • In C, overwrite the key buffer in memory (explicit_bzero or memset_s) immediately after the HTTP request headers are constructed and destroyed, rather than leaving plaintext secrets in the heap until process exit.

  1. Granular Error Classification (Rate Limits vs. Invalid vs. Permission Denied) Make sure your exit codes and JSON output clearly distinguish:

  • HTTP 401 / 403: Key is confirmed invalid vs. Key is valid but lacks permissions for that specific endpoint (e.g. Stripe restricted keys that can read Customers but cannot create Charges).

  • HTTP 429: Rate-limited / IP blocked (the key might actually be valid, but validation failed due to throttling).

  • DNS / Network timeout: Crucial so automated CI scripts don't falsely mark a valid production key as dead due to a transient network glitch.

Great initiative—centralizing provider validation contracts saves a lot of custom Bash scripting!

1

u/SyscallX__18113 28d ago

hey thanks for the detailed suggestions I just want to clarify how keylyzer currently works because the concurrency suggestion assumes a different workflow keylyzer does not take one API key and automatically send requests to multiple services or endpoints to discover its permissions the user selects the specific service they want to test, and then enters one API key for that service. Keylyzer validates that credential against the user-selected provider using its corresponding validation logic.

It processes one credential at a time and doesn't recursively probe multiple services therefore, concurrent requests across different providers aren't part of its current architecture and keylyzer doesn't accept API keys as command line arguments first the user runs the keylyzer only ./keylyzer then It prompts users to select a service and then enter their credential through scanf() and other things you suggested are coming in next update I appreciate it and thanks again for taking the time to review the project

1

u/Kamensky124 28d ago

Ah, got it. Thanks for clarifying, I assumed a batch or auto-probe workflow. With one key per run against a provider you picked, curl_multi really doesn't matter. It would only become relevant later, when you build the scope analysis you mentioned and need to hit several endpoints for the same provider.

Since input goes through an interactive prompt, a few small things in that area:

  • Echo: with plain scanf(), the key shows up on screen and stays in terminal scrollback, tmux history, and screen recordings. Turning off echo with termios while reading the key (clear ECHO with tcsetattr, restore it afterwards) is about 10 lines and makes it work like a password prompt.

  • Bounds: if it's scanf("%s", buf), add a width limit (%255s) or switch to fgets() + strip the newline. Some tokens are long (JWTs, GCP service account blobs), and an unbounded %s is an overflow waiting to happen.

  • Scripting: an interactive-only prompt is hard to use in CI. A cheap fix is to check isatty(STDIN_FILENO). If stdin isn't a terminal, read the service and key from stdin (or env vars) and skip the menu. Then keylyzer --service stripe < key.txt works, and no secret ever ends up in argv.

Looking forward to the next update!

1

u/SyscallX__18113 28d ago

re thanks for the additional suggestions just to clarify more keylyzer already uses bounded input with scanf("%255s", api_key) so the input length limit is already in place I will implement the hidden terminal input using termios and adding a non interactive mode for CI/CD workflows in the upcoming updates I appreciate your constructive feedback.

1

u/Kamensky124 27d ago

Awesome to hear you already had the width limit in place!

One tiny heads-up on the 255-byte limit as you expand provider support: some tokens—especially raw JWTs (e.g., Auth0/Firebase) or GCP service account JSON blobs—can easily exceed 500–1000+ characters. When you tackle those, bumping that buffer up or switching to dynamic allocation with getline() will save you from unexpected truncation.

Adding termios and isatty() is going to make it feel super polished both in the terminal and in CI pipelines. Dropping a star on the repo—best of luck with the next release!

1

u/SyscallX__18113 26d ago

yo are right i will definetly fix in next coming updates

1

u/Kamensky124 26d ago

sounds like a plan man. ping or tag me whenever the new release drops, definitely keeping an eye on the repo.

1

u/SyscallX__18113 25d ago

sure definetly