-
Notifications
You must be signed in to change notification settings - Fork 27
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
Appsec installation help #30
Comments
There two types of forbidden that can be responded, did you get a JSON response body? |
@LaurenceJJones Thanks for helping out! Here are the curl requests I'm running from a shell within my NPM container.
And the malevolent test request:
|
perfect! I wanted to make sure before we dive into debugging it wasnt something as easy as an invalid api key 😅 Within the error log of npm do you see any crowdsec logs? you might have to route around a little as I know npm likes to split the error logs per host. |
I do see crowdsec actions being taken in some of the npm error logs. Here's everything relevant I can find in all my logs, including logs from the time of my test requests and also the crowdsec actions that I do see so far: default-host_access.log is the log file for requests directly to my IP since NPM does not have a host connected to it. We can see NPM catching my test request and returning its 404. There's nothing in the associated default-host_error.log.
fallback_error.log has this from crowdsec, but nothing else from the time of the test request:
proxy-host-1_access.log is the log for one of the subdomains managed by NPM. We can see the webapp here receiving another test request sent to it and responding with its 404 page.
There's nothing in the associated proxy-host-1_error.log from the time of that test request but, curiously, I do see a crowdsec ban line from two days ago for an IP that does not show among the alerts in my crowdsec console. Not sure what that's about.
Looking through the error logs of other hosts in NPM, I see one has a crowdsec ban for that same IP from a different day which is also not in my console alerts. I don't see any other mentions of crowdsec or ban lines in any NPM error logs for the alerts that do exist in my web console. Not sure if this indicates a configuration problem or if this is normal. 🤷 Here's relevant looking info from the crowdsec container log from both the container starting up and the times of the test requests:
|
Just to ask when you added the config to the compose did you recreate the npm container as in It may also be that the environment key is only read once and since the config file might already exist it doesn't repopulate it? |
Also adding within the container if you check |
Well, turns out I do not have that particular conf file. Sounds like that could be a problem? Do I need to manually create that? According to https://docs.crowdsec.net/u/bouncers/openresty, it should be located at For reference, when setting up crowdsec initially, I followed the steps in this repo's readme here and assumed this was all that was needed if the env vars were being set in the docker compose file. |
Yes but npm stores file in different locations, so if you do a find it should be there somewhere. However it won't be under |
Sorry, I missed that reply. I'm not sure if I used a full |
I do not see that or any "*bouncer.conf" files anywhere in the container's filesystem. |
You are checking the npm container right? Checked his repo and it states |
Ah, my bad, I was searching the crowdsec container. I found it in the npm container in Fixing that results in some progress, though now it seems the appsec component is throwing 500 errors with this in the logs:
|
Huh? That should only do this on post requests. Let me check the source over the weekend and see if we have a logic issue. |
Alright, thanks again for helping out; I really appreciate it. Searching the repo I found a couple other issues related to that error, linking them here for reference: The first one is reported by LePresidente and seems like my same error. |
Yeah so we added a check https://github.com/crowdsecurity/lua-cs-bouncer/blob/main/lib%2Fcrowdsec.lua#L427 However, this error is happening from the Lua library itself, however, this was removed from the latest version so I don't know if LePresidente needs to bump the version or even NPM. Don't know if it's useful but I seen a lot more people have success with https://github.com/ZoeyVid/NPMplus |
This is happening for all requests, even legitimate ones so I've disabled the appsec component for now. I pinged LePresidente over in his issue with your question about the version he's using in his NPM fork. We'll see what info he can provide from that. |
As for my original issue of the variable not being updated, perhaps that behavior should be documented in the readme here along with the location of the config file I found within the NPM container? |
@LaurenceJJones FYI while we wait, version info from
|
Update: NPM updated to v2.12.2 and this error has been resolved for me. I do have one more configuration question, @LaurenceJJones, if you don't mind; you've been extremely helpful so far. With that error resolved, accessing In NPM's settings, I can control how NPM responds to these requests in the "Default Site" configuration. The options are |
Yes this is a known limitation, so basically if in your fallback you have something like:
Since nginx tries to optimize the calls on the stack it will not run these against the I had a look earlier in 2024 and there no way to force nginx to run these hooks unless you provide the custom page option as then it is |
That makes sense, thanks for the explanation. From a security perspective, do you guys currently think it's better to leave the fallback set to 404 or provide a custom page so crowdsec can get involved in the requests? It seems to me there's tradeoffs with either option and I'm not quite sure which would be best practice. |
99.99% of the time its fine, the fallback page is a static html page that does not allow any interaction. Personally I use the fallback option to redirect back to my site as with anything if are going directly to the IP address then do you want to spend resources showing them a custom page 🤷🏻 most likely not as standard users are going to type in a fqdn. |
Thanks for all your help, I appreciate it! Everything seems to be working on my end now. |
I am attempting to configure appsec for my crowdsec install on nginx proxy manager. Manual tests sent with curl from my NPM container to the crowdsec container confirm appsec is working, but requests to the web apps that are protected by crowdsec don't seem to be caught by appsec. For example, accessing my http://{ip-address}/.env does not trigger appsec and the request is passed through to NPM.
I'm sure it's just a configuration problem on my end, but I could use some help sorting out what I've done wrong.
Here's what I have so far:
This is my docker-compose file.
A note about the ports below in case it matters: I'm using rootless docker with the pasta network driver and iptables rules to forward privileged->unprivileged ports (pasta can't be bound to privileged ports). This allows the source IPs from web traffic to propagate into my logs for manual inspection when necessary (rootless docker hides these with a default configuration).
This is my acquis.yaml:
The text was updated successfully, but these errors were encountered: